I have no Idea how to fix these errors. It would be cool if someone could assist me.
Here is the code
#include "song.h"
ostream& operator << (ostream& os, Song& obj)
{
os << "title:" << obj.title << " arist:" << obj.artist;
return os;
}
//constructor
Song::Song(string a, string t, int s)
{ // constructor
size = s;
title = t;
strcpy ( title, t );
artist = a;
strcpy ( artist, a );
}
//accessor for name
string Song :: getTitle()
{
return title;
}
//mutator
void Song :: setTitle (string t)
{
name = new string (strlen (t) + 1 );
........
the error
song.cpp: In function `std::ostream& operator<<(std::ostream&, Song&)':
song.h:23: error: `std::string Song::title' is private
song.cpp:6: error: within this context
song.h:24: error: `std::string Song::artist' is private
song.cpp:6: error: within this context
Although the title of the post suggests so, this error can occur if you have declared it as just a global function and trying to access Class Song's pvt members.