主题:如何继承
[b]继承三性。private,protected,public。
感觉protected与public差不多吗,请问是这样吗?请求帮助。[/b]
class p
{
pulbic:
void basic()
{
cout<<"1-9"<<endl;
demo();
DirRun();
}
protected:
void demo()
{
cout<<"Play"<<endl;
}
private:
void DirRun()
{
cout<<"End"<<endl;
}
};
[i]class Pig:protected p //public p[/i]
{
pulbic:
void ABC()
{cout<<"a-z"<<endl;}
protected:
private:
};
class Dog:public Pig
{
pulbic:
void standard()
{
cout<<"A~Z"<<endl;
basic();
}
protected:
private:
};
main()
{
Dog so;
so.standard();
getch();
}
感觉protected与public差不多吗,请问是这样吗?请求帮助。[/b]
class p
{
pulbic:
void basic()
{
cout<<"1-9"<<endl;
demo();
DirRun();
}
protected:
void demo()
{
cout<<"Play"<<endl;
}
private:
void DirRun()
{
cout<<"End"<<endl;
}
};
[i]class Pig:protected p //public p[/i]
{
pulbic:
void ABC()
{cout<<"a-z"<<endl;}
protected:
private:
};
class Dog:public Pig
{
pulbic:
void standard()
{
cout<<"A~Z"<<endl;
basic();
}
protected:
private:
};
main()
{
Dog so;
so.standard();
getch();
}