+ 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; }

4th Apr 2017, 8:26 AM
Unix Man
3 Respostas
+ 11
Doesn't seem to be bugged.
4th Apr 2017, 8:31 AM
Hatsy Rei
Hatsy Rei - avatar
+ 10
Already done...my friend!
4th Apr 2017, 8:37 AM
Dev
Dev - avatar
+ 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.
4th Apr 2017, 12:36 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar