关于虚函数的一段代码,求大神帮忙看下错误的原因

#include <iostream>
using namespace std;
class father
{
public:
virtual void run(){cout<<"父亲的作死率为99%";}
};
class son:public father
{
public:
void run(){cout<<"儿子的作死率为99%";}
};
class daugther:public father
{
public:
void run(){cout<<"女儿的作死率为99%";}
};
class grandson:public father
{
public:
void run(){cout<<"孙子的作死率为99%";}
};
void one(father);
void two(father *);
void three(father &);
void main()
{
father *p=0;
int choice;
bool quit=false;
while(1)
{
cout<<"请选择:0退出 1儿子 2女儿 3孙子\n:";
cin>>choice;
switch(choice)
{
case 0:quit=true;
break;
case 1:p=new son;
one(*p);
break;
case 2:p=new daugther;
two(p);
break;
case 3:p=new grandson;
three(*p);
break;
}
if (quit==true)
{
break;
}
}

}
void one(father)
{
one.run();
}
void two(father *)
{
two->run();
}
void three(father &)
{
three.run();
}
编译器提示错误在最下的三个函数,本人C++菜鸟,求大神耐心指点一下,是否还有想关联的知识,也请讲讲

第1个回答  2014-06-20
one.run();?这是什么玩意,函数调用函数么???

写错饿了吧
相似回答