Why would a Dog need Cat functions? If it needs that, then the design should be flawed.
You should try to keep functionality that both classes need in a common base class, but it should also be...
Type: Posts; User: Elysia
Why would a Dog need Cat functions? If it needs that, then the design should be flawed.
You should try to keep functionality that both classes need in a common base class, but it should also be...
There's also still two problems in the code:
1) You are creating an Animal. Animal != Dog. So you are treading a very fine line when you're casting the Animal into a Dog. It's would be another thing...
Several issues...
You are trying to convert a pointer to a non-pointer. You want to change the type of your Animal* to Dog* (both pointers). Use dynamic_cast for this, because we're working with...
This is polymorphism, btw, a separate topic.
Since Dog inherits from Animal, it is also an Animal, thus you can convert a Dog into an Animal without problems, no casting required. That's not always...
Because you try to dereference a non-pointer? o_O
You can add as many constructors as you want.
The form would be:
Dog(const Animal& rhs)
Dog is the constructor (naturally), which must take an Animal as argument (the object which it's going to...
It says EITHER
a) No constructor could do the conversion
b) Constructor overload was ambiguous (two or more constructors was found that could do the conversion, but the compiler couldn't choose a...