programming-examples/c++/Overview/CPP Program to Implement Operator Overloading Including Unary and Binary Operators.cpp

45 lines
663 B
C++
Raw Normal View History

2019-11-18 14:44:36 +01:00
// Start the program
// Create the class
// Write the function to implement unary +, - and =
// Write the function to implement binary +
// Create the instance and pass the value for the function
// Call the overloaded function and equate it to another object
// Compile and run the program
#include<iostream.h>
class myclass
{
int a, b;
public:
void init(int i, int j);
{
a = i;
b = j;
}
void show();
{
cout<<a=<<a<<\n;
cout<<b=<<b<<\n;
}
};
int main()
{
myclass x;
x.init(10, 20);
x.show();
return 0;
}