I'm working on a small C++ project that requires using classes. I'm supposed to create a super class Animal and the sub classes Fish, Bird and Insect. In the main function, the object of type animal is created. I need that object to 'become' one of the 3 other types at random (each sub class has a different number of legs). Any Idea how to do that? Thanks
xcorpionxting
0
Newbie Poster
Recommended Answers
Jump to PostObjects in C++ can't change their type. You can have a variable of some pointer-to-animal type and then assign a new pointer-to-animal to that variable though.
All 3 Replies
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
twomers
408
Posting Virtuoso
xcorpionxting
0
Newbie Poster
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.