lundi 16 mars 2015

class myString new programmer


class mystring {


public:



mystring(const char x[])
: capacity(1024)
{
for (int i = 0; i < capacity; ++i)
{
if (x[i] == '\0') break;
s[i] = x[i];
length++;
}
}
mystring()
: capacity(1024), s('\0'), length(0)
{}


//etc...


private:



const int capacity;
char s[1024];
int length;


};


I'm getting this error:


In file included from main.cpp:19:0: mystring.h: In constructor ‘mystring::mystring()’: mystring.h:21:44: error: incompatible types in assignment of ‘char’ to ‘char [1024]’ : capacity(1024), s('\0'), length(0) I don't under stand what's going on. I'm a bit new to constructors. Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire