Last active
August 29, 2015 14:22
Revisions
-
omkarnathsingh revised this gist
Jun 5, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,8 @@ public: void display() { cout<<"\nReal Part: "<<a; cout<<"\tImaginary Part: "<<b<<" i"; } //Prototypes -
omkarnathsingh revised this gist
Jun 5, 2015 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ * Created on: 03-Jun-2015 * Author: omkarnathsingh */ #include<iostream> using namespace std; @@ -28,9 +30,13 @@ public: } //Prototypes //to pass operand as reference parameter Complex operator=(Complex op2); //prefix version friend Complex operator++(Complex &op); //postfix version friend Complex operator++(Complex &op,int x); }; Complex Complex::operator=(Complex op2) { -
omkarnathsingh created this gist
Jun 3, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ /* * Source.cpp * * Created on: 03-Jun-2015 * Author: omkarnathsingh */ #include<iostream> using namespace std; class Complex { int a,b; public: //Constructors Complex() { a=0; b=0; } Complex(int m,int n) { a=m; b=n; } void display() { cout<<"\nReal Part: "<<a<<"\tImaginary Part: "<<b<<" i"; } //Prototypes Complex operator=(Complex op2); //to pass operand as reference parameter friend Complex operator++(Complex &op); //prefix version friend Complex operator++(Complex &op,int x); //postfix version }; Complex Complex::operator=(Complex op2) { a=op2.a; b=op2.b; return *this; } Complex operator++(Complex &op) { op.a++; op.b++; return op; } Complex operator++(Complex &op,int x) { op.a++; op.b++; return op; } int main() { Complex ob1; ob1.display(); ++ob1; ob1.display(); ob1++; ob1.display(); return 0; }