Jul 1, 2017 #1 C computerwork Banned Joined Jun 28, 2017 Messages 14 Helped 2 Reputation 4 Reaction score 2 Trophy points 3 Activity points 0 hello please explain this using namespace std; class Mathematics { int x, y; public: void input() { cout << "Input two inetegers\n"; cin >> x >> y; } void add() { cout << "Result = " << x + y; } }; int main() { Mathematics m; // Creating object of class m.input(); m.add(); return 0; getchar(); getchar(); }
hello please explain this using namespace std; class Mathematics { int x, y; public: void input() { cout << "Input two inetegers\n"; cin >> x >> y; } void add() { cout << "Result = " << x + y; } }; int main() { Mathematics m; // Creating object of class m.input(); m.add(); return 0; getchar(); getchar(); }
Jul 8, 2017 #2 H horace1 Advanced Member level 5 Joined Nov 18, 2008 Messages 2,118 Helped 596 Reputation 1,188 Reaction score 571 Trophy points 1,393 Location Norwich, UK Activity points 13,063 Re: how this c++ oops code is working? the method m.input() reads the values of x and y (global class variables) and method m.add() adds the values and prints the result use code tags
Re: how this c++ oops code is working? the method m.input() reads the values of x and y (global class variables) and method m.add() adds the values and prints the result use code tags