1 #include<iostream> 2 using namespace std; 3 class Mammal 4 { 5 public: 6 Mammal() 7 { 8 cout<<"Mammal constructor...\n"; 9 } 10 ~Mammal() 11 { 12 cout<<"Mammal speak!\n"; 13 } 14 virtual void speak() 15 { 16 17 } 18 }; 19 class Dog:public Mammal 20 { 21 public: 22 Dog() 23 { 24 cout<<"Dog Constructor...\n"; 25 } 26 ~Dog() 27 { 28 cout<<"Dog destructor...\n"; 29 } 30 void speak() 31 { 32 cout<<"Woof\n"; 33 } 34 }; 35 int main() 36 { 37 Mammal*pDog=new Dog; 38 pDog->speak(); 39 delete pDog; 40 return 0; 41 }
标签:std,39,return,5.5,coutspeak,Mammal From: https://www.cnblogs.com/lijianlongCode13/p/17383348.html