Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How this c++ oops code is working?

Status
Not open for further replies.

computerwork

Banned
Newbie level 6
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();
}
 

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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top