首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

VC2008中引用指针有关问题

2013-02-15 
VC2008中引用指针问题。#include iostreamusing namespace stdclass Animal{public:void breathe(){cout

VC2008中引用指针问题。
#include <iostream>
using namespace std;

class Animal
{
public:
void breathe()
{
cout<<"animal breathe"<<endl;
}
};
class Fish : public Animal
{
public:
void breathe()
{
cout<<"fish bubble"<<endl;
}
};

void fn(Animal *pan)
{
pan->breathe();
}
void main()
{

Fish fh;
Animal *pan;
pan=&fh;
fh(pan);
getchar();
}
红色的一行出现 error C2064: 项不会计算为接受 1 个参数的函数,
我看视频是VC6.0的讲解,在VC2008里面试的。为什么会发生这个问题?如何解决?
[解决办法]
void fn(Animal *pan)
fh(pan);

自己输错了。。。。。。。。
[解决办法]
把函数名改成fn这样就可以编译通过
因为你定义了一个Fish对象fh。而函数名也是fh,所以会出现这个错误。

热点排行