error: expected ')' before '<' token|
I was implementing a String and was giving the definition in .h file. The code in String.h is the following:
#include<list>
class String
{
public:
String();//Constructor
String(char * copy);//For converting CString to String
const char *c_str(const String ©);//For converting String to Cstring
String(list<char> ©);//Copying chars from list
//Safety members
~String();
String(const String ©);
void operator = (const String ©);
protected:
int length;
ch开发者_如何学JAVAar *entries;
};
The error is mentioned in the subject. What is it that I am not following?
You are missing a std::
in front of list<char>
:
String(std::list<char> ©);
Fixed several of your issues at once:
#include <list>
class String
{
public:
String();
String(const String &c);
String(const char * c);
String(std::list<char> c); // No idea why someone would have this constructor, but it was included in the original ...
~String();
String& operator = (const String &c);
const char *c_str();
private:
unsigned int length;
char* entries;
};
精彩评论