| | |
Multiple Inhetitence
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 34
Reputation:
Solved Threads: 0
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
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.
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()
{
cout << Track_Pop.getTrackGenre() << endl
<< Track_Rock.getTrackGenre() << endl;
}Could anyone suggest a way of outputting the genre of the two base classes in the derived class?
Thanks,
G.
•
•
Join Date: Nov 2007
Posts: 34
Reputation:
Solved Threads: 0
I just realised that I put in
twice. One of those should be:
C++ Syntax (Toggle Plain Text)
string Track_Pop::getTrackGenre() { return "Pop track"; }
twice. One of those should be:
C++ Syntax (Toggle Plain Text)
string Track_Rock::getTrackGenre() { return "Rock track"; }
![]() |
Similar Threads
- Multiple webcams (USB Devices and other Peripherals)
- Close Multiple Windows (Windows tips 'n' tweaks)
- Managing Multiple Photos or Other Files (Windows tips 'n' tweaks)
- How to Rename Multiple Files with Windows Explorer (Windows tips 'n' tweaks)
- Multiple IE starting (Web Browsers)
- Can't close multiple IE windows (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: help me plzzzzzzzzzz
- Next Thread: invention
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





