Lecture 22
Overloading Operator
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
int num1=2;
cout <<" num value : "<<num1;
num1=num1+1;
cout <<"\n One increment value : "<<num1;
cout <<"\n Two increment value : "<<num1+2;
cout <<"\n Three increment value : "<<num1+3;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
int num1=6;
cout <<" num value : "<<num1;
num1=num1-1;
cout <<"\n One decrement value : "<<num1;
cout <<"\n Two decrement value : "<<num1-2;
cout <<"\n Three decrement value : "<<num1-3;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10