Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Animal
- {
- public:
- void move();
- };
- void Animal::move()
- {
- std::cout << "Moving generically." << std::endl;
- }
- class Fish : public Animal
- {
- public:
- void move();
- };
- void Fish::move()
- {
- std::cout << "Swimming, because that's what fish do." << std::endl;
- }
- int main()
- {
- Animal *bob = new Fish();
- bob->move();
- ((Fish *)bob)->move();
- }
Advertisement
Add Comment
Please, Sign In to add comment