#include
class Mammal
{
public:
Mammal():itsAge(1) {std::cout<<"Mammal consructor...\n";}
~Mammal() {std::cout<<"Mammal destructor...\n";}
void Move()const {std::cout <<"Mammal move onte step\n";}
virtual void Speak() const {std::cout<<"Mammal speak!\n";}
protected:
int itsAge;
};
class Dog : public Mammal
{
Dog() {std::cout << "Dog consrtuctor...\n";}
~Dog() {std::cout << "Dog desrtuctor...\n";}
void WagTail() {std::cout <<"Wagging Tail...\n";}
void Speak() const {std::cout<<"Woof!\n";}
void Move() const {std::cout <<"Dog moves 5 steps...\n";}
};
int main()
{
Mammal *pDog = new Dog;
pDog->Move();
pDog->Speak();
return 0;
}
******************************************
error C2248: 'Dog::Dog' : cannot access private member declared in class 'Dog'
see declaration of 'Dog::Dog'
竟会有错误,,怎么也想不通,高手帮帮忙.谢谢啦
--------------------next---------------------
阅读(1088) | 评论(0) | 转发(0) |