在类内部起作用

时间:2019-03-31 19:57:39

标签: c++ function class

嗨,伙计们,我真的希望您能解决这个问题……每当我在其下写下该代码时,它说“答案是”,但并没有给我答案..... pleeeeease给我写代码

#include <iostream>
using namespace std;
class steve{
public:

int adding(int a,int b){
int sum=a+b;
return sum;

}

};
int main(){

int a;
int b;
cout<<"enter a number you want to add"<<endl;
cin>>a;
cout<<"enter the other number"<<endl;
cin>>b;

cout<<"the answer is"<<endl;
steve steveObject;
steveObject.adding(a,b);

}

1 个答案:

答案 0 :(得分:0)

您没有输出结果:

steve steveObject;
cout << "the answer is " << steveObject.adding(a,b) << endl;