永发信息网

C++高手进

答案:2  悬赏:0  手机版
解决时间 2021-01-25 15:17
  • 提问者网友:难遇难求
  • 2021-01-25 02:56
#include
using namespace std;
class Veichle
{
public:
Veichle(double w=0)
{
cout<<"Veichle constructor"< weight = w;
}
void setWeight(double w)
{
cout<<"set weight ="< weight = w;
}
protected:
double weight;
};
class Veichle_Road: virtual public Veichle
{
public:
Veichle_Road( double weight = 0,int s=0):Veichle(weight)
{
cout<<"Veichle_Road constructor"< speed = s;
}
protected:
int speed;
};
class Veichle_Water:virtual public Veichle
{
public:
Veichle_Water(double weight = 0,float t = 0):Veichle(weight)
{
cout<<"Veichle_Water constructor"< tonnage = t;
}
protected:
float tonnage;
};
class Amphicar:public Veichle_Road,public Veichle_Water
{
public:
Amphicar( double w, int s,float f)
:Veichle_Road(w,s),Veichle_Water(w,f)
{
cout<<"Amphicar constructor"< }
void display()
{
cout<<"Amphicar object contains:"< cout<<"weight:"< cout<<"speed:"< cout<<"tonnage:"< }
};

int main()
{
Amphicar amp(4.0,200,1.5f);
amp.setWeight(2.0);
amp.display;
return 0;
}
这个程序无法通过编译的 在dev-C++上
显示的错误是:
62 D:\asdasdf.cpp statement cannot resolve address of overloaded function
哪个高手给我说下啊 谢谢!!
最佳答案
  • 五星知识达人网友:往事隔山水
  • 2021-01-25 03:42
amp.setWeight(2.0);
amp.display();//少个括号...VS2005运行成功
全部回答
  • 1楼网友:刀戟声无边
  • 2021-01-25 04:51

#include <iostream> using std::cout; using std::endl;

class cat{  char name[255];  unsigned age;  double weight; public:  void miaow(){   cout << "喵~喵" << endl;  } };

int main(void){  cat cat;  cat.miaow();  system("pause"); }

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯