Write a program in C++ of addition of two nos by passing argument to the member function
#include<iostream.h>
class add { private: int a,b; public: void assign(int x,int y) { a=x; b=y; } void display() { cout << a<<"+"<<b<<"="<<(a+b); } }; void main() { int n1,n2; add o1; cout <<"enter two nos for addition"<<endl; cin >> n1 >>n2; o1.assign(n1,n2); o1.display(); } |