Cipher
Cipher

Reputation: 6082

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 &copy);//For converting String to Cstring
    String(list<char> &copy);//Copying chars from list
    //Safety members
    ~String();
    String(const String &copy);
    void operator = (const String &copy);
    protected:
    int length;
    char *entries;
};

The error is mentioned in the subject. What is it that I am not following?

Upvotes: 1

Views: 610

Answers (2)

Zac Howland
Zac Howland

Reputation: 15872

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;
};

Upvotes: 1

icecrime
icecrime

Reputation: 76745

You are missing a std:: in front of list<char> :

String(std::list<char> &copy);

Upvotes: 7

Related Questions