You are on page 1of 2

#include <iostream>

#include<conio.h>

using namespace std;

class temp

private:

int data;

public:

void getvalue()

cin>>data;

temp operator+(temp ob)

temp t;

t.data=data + ob.data;

return t;

temp operator- (temp ob)

temp t;

t.data = data - ob.data;

return t;

}
int display()

return data;

};

int main()

temp obj1, obj2, sum, sub;

cout<<"enter an integer value for obj1: ";

obj1.getvalue();

cout<<"Enter an integer value for obj2: ";

obj2.getvalue();

sum= obj1+obj2;

sub=obj1-obj2;

cout<<"Addition result is = "<<sum.display()<<endl;

cout<<"Subtraction result is = "<<sub.display()<<endl;

getch

You might also like