c++ - 类中的函数
问题描述
嗨,伙计们,我真的希望您能帮我解决这个问题……每当我在下面写下该代码时,它都会说“答案是”,但它没有给我答案……请给我写代码
#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);
}
解决方案
您没有输出结果:
steve steveObject;
cout << "the answer is " << steveObject.adding(a,b) << endl;
推荐阅读
- css - 图片 CSS 的宽度问题
- c++ - 为什么我的代码是错误的?:数字系统的简单转换
- c++ - 投原子是否安全
到 T - python - 如何根据 django 中选择的“id”自动填写表单
- python - 如何使用 Python 中的另一个函数调用带参数的函数
- python - 提取带有已定义词的句子限制,不包括单词 itef
- html - 在多个嵌套的弹性框内滚动
- laravel - 如何在 laravel 8 中使用 md5 而不是 bcrypt 对密码进行哈希处理?
- amazon-web-services - 可以在对等 vpc 中调用 aws 接口端点吗?
- python - sklearn TfidfVectorizer 给出 MemoryError