Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2342285
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:01:42



#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) |
给主人留下些什么吧!~~