0
why that code doesn't work?
i learn about classes and try to make simple one, but it doesn't work. it suppose just to print a number, but clearly i have made some mistake. please tell my what i did wrong. thank you. https://code.sololearn.com/c0j5bqxi9TOt/?ref=app https://code.sololearn.com/c0j5bqxi9TOt/?ref=app
2 Answers
0
You just forget brackets
#include <iostream>
using namespace std;
class parents{
public:
parents (int x,int y){
dad = x;
mom = y;
}
void combine(){
cout << dad + mom;
}
private:
int dad;
int mom;
};
int main(){
parents shar(34,23);
shar.combine();
return 0;
}
+ 1
thank you very much