我正在实现一个String并在.h文件中给出定义。 String.h中的代码如下:
#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;
char *entries;
};
主题中提到了错误。我不跟踪的是什么?
答案 0 :(得分:7)
您在std::
前面缺少list<char>
:
String(std::list<char> ©);
答案 1 :(得分:1)
一次解决了几个问题:
#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;
};