Que - make a program for classes and objects?
#include<iostream>
using namespace std;
class krishna
{
int num1, num2 ;
public:
void getdata ()
{
cout<<"enter a number :";
cin>>num1;
cout<<"enter a number :";
cin>>num2;
}
void display ()
{
num1=num1+num2;
cout<<"sum of two numbers is :"<<num1;
}
};
int main()
{
krishna ob ;
ob. getdata();
ob. display();
return 0;
}
Result:-