123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <iostream>
- using namespace std;
- class Mammal {
- public:
- Mammal() {
- cout << "Mammal constructor" << endl;
- }
-
- virtual ~Mammal() {
- cout << "Mammal destructor" << endl;
- }
- };
- class Dog : public Mammal {
- public:
- Dog() {
- cout << "Dog constructor" << endl;
- }
-
- virtual ~Dog() {
- cout << "Dog destructor" << endl;
- }
-
- void speak() {
- cout << "wang wang" << endl;
- }
- };
- void creating() {
- Dog dog;
- dog.speak();
- }
- int main() {
- creating();
-
- return 0;
- }
|