回 帖 发 新 帖 刷新版面

主题:求助啊, 高手帮忙啊!!


求助啊, 代码是:
#include <iostream.h>

class Animal
{
public:
    Animal(int height,int weight)
    {
        cout<<"animal construct"<<endl;
    }
    ~Animal()
    {
        cout<<"animal deconstruct"<<endl;
    }
    void eat()
    {
        cout<<"animal eat"<<endl;

    }

    void sleep()
    {
        cout<<"animal sleep"<<endl;
    }

virtual void breathe()
    {
        cout<<"animal breathe"<<endl;
    }
};
class Fish : public Animal
{
public:
    Fish():Animal(400,300),a(1)
{
    cout<<"fish construct"<<endl;
}
~Fish()
{
    cout<<"fish deconstruct"<<endl;
}
void breathe()
{

    cout<<"fish bubble"<<endl;
}
private :
    const int a;
    
};
void fn(Animal *pAn)
{
    pAn->breathe();
}

void main()
{

Fish fh;
Animal *pAn;
pAn=&fh;
fh(pAn);

}

错误代码:Main.cpp(82) : error C2064: term does not evaluate to a function
高手帮忙啊!! 谢谢拉

回复列表 (共2个回复)

沙发


你最后一句写错了!fh(pAn); 应该是fn(pAn);

板凳

哈哈, 好了, 已经搞定了~~!!!  非常感谢啊!!!
以后多向大师学习呀, 请赐教哦@@

[em11][em12]

我来回复

您尚未登录,请登录后再回复。点此登录或注册