diggindog
diggindog

Reputation: 1

Member Function Error

class recording
{
public:
    void setTitle(const string &);
    void setArtist(const string &);

    string getTitle(void) const;
    string getArtist(void) const;

private:
    string title;
    string artist;
};


void recording::setTitle(string & pTitle)
{
    title = pTitle;
}

This is telling me that my declaration is incompatible with my function header. But if I don't use the scope resolution operator it says title is undefined. This doesn't make sense to me cuz that is how you declare a member function.

Upvotes: 0

Views: 36

Answers (1)

LihO
LihO

Reputation: 42083

The const makes the difference. You have declared:

void setTitle(const string &);

but you tried to define:

void recording::setTitle(string & pTitle)

Upvotes: 4

Related Questions