Hi all,

Just have a curiosity about multiple inheritance. I have defined two classes, each of which returns a string to described an object of that class. I have also made another class which inherits from both of the above classes. I want to define a function in the derived class to output both of the strings from the base classes. This is

class Track_Rock
{
public:

	string getTrackGenre();
};

class Track_Rock
{
public:

	string getTrackGenre();
};

class Track_PopRock: public Track_Rock, public Track_Pop
{
public:

	void combinedGenre();
};

string Track_Pop::getTrackGenre() 
{ 
	return "Pop track";
}

string Track_Pop::getTrackGenre() 
{ 
	return "Pop track";
}

void Track_PopRock::combinedGenre()
{
	[B]cout << Track_Pop.getTrackGenre() << endl
		 << Track_Rock.getTrackGenre() << endl;[/B]
}

I get an error: "error C2275: 'Track_PopRock::Track_Pop' : illegal use of this type as an expression".
Could anyone suggest a way of outputting the genre of the two base classes in the derived class?
Thanks,
G.

I just realised that I put in

string Track_Pop::getTrackGenre() 
{ 
	return "Pop track";
}

twice. One of those should be:

string Track_Rock::getTrackGenre() 
{ 
	return "Rock track";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.