我在调试此代码中的错误方面遇到了麻烦,并且无法理解我哪里出错了?
#include <iostream>
using namespace std;
class man
{
int age;
int height;
int weight;
public:
int data(void);
void initialize(int,int,int);
};
int man::data(void)
{
return (age*height)/weight;
};
void man::initialize(initial_age,initial_height,initial_weight)
{
age = initial_age;
height = initial_height;
weight = initial_weight;
};
int main()
{
man tim,crook;
tim.initialize(19,178,55);
crook.initialize(28,171,71);
cout << "THE DATA IS AS SHOWN FOR tim" << tim.initialize() << endl;
cout <<"THE DATA IS AS SHOWN FOR crook" << crook.initialialize() << endl;
}
答案 0 :(得分:0)
我用肉眼观察到man::initialize
方法的实施出错。它的参数没有类型。添加int
类型。
void man::initialize(int initial_age, int initial_height, int initial_weight)
{
age = initial_age;
height = initial_height;
weight = initial_weight;
};