+ 2
Do it
#include <iostream> using namespace std; class item { int a,b; public: int sum; void getdata(); void do_sum() { sum = a+b; } }; void item::getdata() { cout << "enter value"; cin >> a >> b; } int main() { item x; cout << "\nobject x " << "\n"; x.getdata(); x.do_sum(); cout << x.sum; return 0; }
3 Respostas
+ 11
Doesn't seem to be bugged.
+ 10
Already done...my friend!
+ 4
Are you running this in code playground and not getting "enter value" before entering input?
If that's the case, it's how Sololearn code playground works. You have to provide all inputs at once.