The trouble is you think you have time. Your success depends on how you utilize your time.
Add two Numbers using Classes and Objects, with the help of Functions.
How can we add Two numbers Using Classes and Objects, and also print them through class in C++:
#include<iostream>
#include<conio.h>
using namespace std;
class complex
{
private:
int a, b,c;
public:
int add(int x,int y)
{
a=x; b=y;
c=a+b;
return c;
}
int print()
{
cout<<endl<<"your Sum is: "<<c;
}
};
int main()
{
cout<<" Moznum.blogspot.com"<<endl<<endl;
int c,v;
complex a;
cout<<"Enter the first value: ";
cin>>c;
cout<<"Enter the Second value: ";
cin>>v;
a.add(c,v);
a.print();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment