I've been banging my head on this errors and can't seem to find where I went wrong. For any of the "set_" errors, set_ (as well as print) refers to a member function of another class . Please, any help would be great.
test.cpp: In member function `void CDCollection::get(int, std::ofstream&)':
error: `print' is not a type
error: request for member of non-aggregate type before '(' token
test.cpp: In member function `void CDCollection::add(std::istream&)':
error: `set_artist' has not been declared
error: request for member of non-aggregate type before '(' token
error: `set_title' has not been declared
error: request for member of non-aggregate type before '(' token
error: `set_year' has not been declared
error: request for member of non-aggregate type before '(' token
error: `set_descrip' has not been declared
error: request for member of non-aggregate type before '(' token
Execution terminated
class:
class CDCollection
{
public:
CDCollection();
void print(ofstream &output);
void get(int num_cds, ofstream &out);
void add(istream& in);
private:
int num_cds, cdTotal, max;
char cdArray[100];
};
CDCollection::CDCollection()
{
cdTotal = 0;
}
void CDCollection::get(int num_cds, ofstream &out)
{
cdArray[num_cds].print(out);
}
void CDCollection::print(ofstream &out)
{
out << "CD COLLECTION:" << endl;
for (int num_cds = 0; num_cds < cdTotal; num_cds++)
{
get(num_cds, out);
}
}
void CDCollection::add(istream& in)
{
max = 100;
if (cdTotal < max)
{
SString artist;
SString title;
SString descrip;
SString test;
int year;
char plus[10];
in >> artist;
in >> title;
in >> year;
in.getline(plus,10);
in >> test;
while(1)
{
if (test.str_compare("END\n") == 0)
{
break;
}
SString new_line("\n",1);
descrip + test;
descrip + new_line;
in >> test;
}
cdArray[cdTotal].set_artist(artist);
cdArray[cdTotal].set_title(title);
cdArray[cdTotal].set_year(year);
cdArray[cdTotal].set_descrip(descrip);
cdTotal = cdTotal + 1;
}
else
{
cout << "Error: Exceeded the maximum of 100 CD's in the collection" << endl;
}
}