c++ - class myString new programmer -


class mystring {  public:      mystring(const char x[])         : capacity(1024)     {         (int = 0; < 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 error:

in file included main.cpp:19:0: mystring.h: in constructor ‘mystring::mystring()’: mystring.h:21:44: error: incompatible types in assignment of ‘char’ ‘char [1024]’          : capacity(1024), s('\0'), length(0) 

i don't under stand what's going on. i'm bit new constructors. in advance!

change s('\0') s("\0")

when use single quotes, it's single character. must use double quotes test string.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

c# - ItextSharp font color issue in ver 5.5.4+ -

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -