#include <iostream>
using namespace std;
class calculator{
public:
int setadd(int x,int y){
answer=x+y;
}
int getadd(){
return answer;
}
private:
int answer;
};
int main(){
calculator bo;
bo.setadd(30,7);
cout<<bo.getadd();
return 0;
}
int setadd(int x,int y)
{
[COLOR="#FF0000"]int[/COLOR] answer; [COLOR="#FF0000"]// You want to use the member variable so you don't have to redefine it. This line is useless.[/COLOR]
answer=x+y;
}
int getadd()
{
return answer;
}
private:
int answer;
};
Copyright © 2024, NextGenUpdate.
All Rights Reserved.