okay, I've got a class with two pointers to strings, but I can't figure out how to call the length() function of the default string class (it exists doesn't it?). here's what I've been trying to do:
I'm compiling with g++ and I keep getting a syntax error that says:Code:typedef string* strptr; class Book { public: //big 3 ... ... Book(const Book& b1); //other functions, not important right now ... private: strptr title; strptr author; ... }; //copy constuctor for class Book Book::Book(const Book& b1) { strptr t, a; t = b1.title; a = b1.author; title = new string[t.length()]; author = new string[a.length()]; ... ... }
error: 'length' has not been declared
error: request for member of non-aggregate type before '(' token
I also tried it with:
but that gives me this message:Code:title = new string[t&.length()]; author = new string[a&.length()];
error: expected primary-expression before '.' token
what am I doing wrong?