Explore a little.C ProgrammingC++HTMLVisual BasicSystem AnalysisE-CommerceBCA Notes
LEARN SOMETHING NEW

C++ Program to add two numbers using class

Read4BCA learning libraryFree access

C++ Program to add two numbers using class

//C++ Program to add two numbers using class
//header files
#include<iostream.h>
#include<conio.h>

//creating class
class adding
{

int x,y;

public:

void input()
{

cout<<"Enter two numbers to add\n";
cin>>x>>y;

}
void add()
{

cout<<"addition of two numbers:"<<x+y;

}

};

void main()
{

clrscr();
adding a;        //creating an object of class
a.input();
a.add();
getch();

}
//Now run the program by ctrl+f9

Output

C++ Program to add two numbers using class example

You can also see a video how to run this program

This lesson preserves the original Read4BCA material. Some programming examples use older tools and syntax. View original page.