Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/148.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 类中的函数_C++_Function_Class - Fatal编程技术网

C++ 类中的函数

C++ 类中的函数,c++,function,class,C++,Function,Class,嗨,伙计们,我真的希望你们帮我解决这个问题……每当我在下面写下代码时,它会说“答案是”,但它不会给我答案……请给我写下代码 #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 wan

嗨,伙计们,我真的希望你们帮我解决这个问题……每当我在下面写下代码时,它会说“答案是”,但它不会给我答案……请给我写下代码

#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);

}
#包括
使用名称空间std;
史蒂夫班{
公众:
整数相加(整数a,整数b){
整数和=a+b;
回报金额;
}
};
int main(){
INTA;
int b;

cout您没有输出结果:

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

cout您没有输出结果:

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