#include <iostream> #include<conio.h> using namespace std; class sample { private: int x; public: sample(); void display(); friend void operator++(sample &ob2); }; sample::sample() { x=0; } void sample::display() { cout<<x; } void operator++(sample &ob1) { ++ob1.x; } int main() { sample ob1; ob1.display(); ++ob1; ob1.display(); getch(); }
&
.x
x
sample
operator++
ob2
friend
this
ob1
++ob1.x
getch
#include conio.h
class sample { public: sample():x(0) { }; void display(); void operator ++ () { ++x; } // prefix void operator ++ (int) { x++; } // postfix private: int x; };
Quote:sir is my code incomplete?
Postfix
prefix
void
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)