Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
operator++
//g++ 5.4.0 #include <iostream> using namespace std; class complex { int r,i;//real,imaginary public: complex(int a,int b) //constructor for getting values { r=a; i=b; } complex() {} void display() { cout<<"no is "<<r <<" + "<<i<<" i \n"; } friend complex operator++(complex &a); friend complex operator++(complex &a,int ); }; complex operator++(complex &a)//for ++n1 { a.r=a.r+1; a.i=a.i+1; return a; } complex operator++(complex &a,int )//for n1++ { a.r=a.r+1; a.i=a.i+1; return a; } int main() { cout << "Hello, world!\n"; complex n1(1,1); n1.display(); ++n1; n1.display(); n1++; n1.display(); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Shultz_Lab1.CPP
DeltaX campus recruitment
ledproject
creating triangle using nested loop
pointer to template function
so
GCC compiler bug (should output 0 1)
cpp ex 3 - solution
Pointer to class members
Bin Tree build
Please log in to post a comment.