Im having trouble subclassing a dog and cat as children of parent class Pet.
I am more used to writing Java and dont seem to be grasping the syntax of how to do this. Any help, advice, tips would be greatly greatly appreciated. I dont need you to do the assignment for me but point me in the right direction as how to subclass these classes using contructors(teacher said body of constructor has to be empty for full credit) and as well as how to write the virtual methods.
Pet * pet = NULL;
Dog * mine = new Dog( "Muffin", 1, "Standard Poodle" );
Cat * yours = new Cat( "Sunset", 2, "Calico" );
cout << "These methods work on cat instances" << endl;
yours->feed( );
yours->pet( );
yours->speak( );
cout << "These methods work on dog instances" << endl;
mine->feed( );
mine->pet( );
mine->speak( );
pet = mine;
cout << "These methods work on pet pointers to a dog" << endl;
pet->feed( );
pet->pet( );
pet->speak( );
pet = yours;
cout << "These methods work on pet pointers to a cat" << endl;
pet->feed( );
pet->pet( );
pet->speak( );
// Why doesn't this compile???
// Pet * aPet = new Pet( "name", 12 );
////////////////////////////////////////////////////////////////////
Sample Output
These methods work on cat instances
Sunset walks away...
Sunset purrs...
Sunset walks away...
These methods work on dog instances
Muffin chows down!
Muffin yelps!
Muffin barks!
These methods work on pet pointers to a dog
Muffin chows down!
Muffin yelps!
Muffin barks!
These methods work on pet pointers to a cat
Sunset walks away...
Sunset purrs...
Sunset walks away...
I'm getting errors and things that i believe are easily fixable and messed up by syntax
Thank you guys a lot in advanced!!! I appreciate all the help!