#include<iostream>
#include<stdio.h>
using namespace std;
class INT
{
friend ostream& operator << (ostream& os,const INT& i);
public:
INT(int i):m_i(i){printf("m_i...\n");};
INT& operator++()
{
printf("pre ++\n");
++(this->m_i);
return *this;
}
const INT operator++(int)
{
printf("post ++\n");
INT temp = *this;
++(*this);
return temp;
}
INT& operator--()
{
--(this->m_i);
return *this;
}
const INT operator--(int)
{
INT temp = *this;
--(*this);
return temp;
}
int & operator*()const
{
return (int&)m_i;
}
private:
int m_i;
};
ostream& operator<<(ostream& os,const INT& i)
{
os << '[' << i.m_i << ']'<<endl;
return os;
}
int main()
{
INT I(5);
cout<< ++I;
//cout<< ++I;
//cout<< I--;
//cout<< --I;
//cout<< *I;
cout<<endl;
}
#include<stdio.h>
using namespace std;
class INT
{
friend ostream& operator << (ostream& os,const INT& i);
public:
INT(int i):m_i(i){printf("m_i...\n");};
INT& operator++()
{
printf("pre ++\n");
++(this->m_i);
return *this;
}
const INT operator++(int)
{
printf("post ++\n");
INT temp = *this;
++(*this);
return temp;
}
INT& operator--()
{
--(this->m_i);
return *this;
}
const INT operator--(int)
{
INT temp = *this;
--(*this);
return temp;
}
int & operator*()const
{
return (int&)m_i;
}
private:
int m_i;
};
ostream& operator<<(ostream& os,const INT& i)
{
os << '[' << i.m_i << ']'<<endl;
return os;
}
int main()
{
INT I(5);
cout<< ++I;
//cout<< ++I;
//cout<< I--;
//cout<< --I;
//cout<< *I;
cout<<endl;
}