728x90
#include <iostream>
using namespace std;

class Digit
{
private:
	int m_digit;
public:
	Digit(int digit = 0)
		: m_digit(digit)
	{}

	// prefix 전위형
	Digit& operator ++ () {
		++m_digit;
		return *this;
	}
	
	// post 일경우 더미로 아무거나 넣어준다.
	Digit operator ++ (int) {
		Digit temp(m_digit);
		++(*this);
		return temp;
	}

	friend ostream& operator << (ostream& out, const Digit& d) {
		out << d.m_digit;
		return out;
	}
};

int main()
{
	Digit d(5);

	cout << ++d << endl;
	cout << d << endl;

	cout << d++ << endl;
	cout << d << endl;

	return 0;
}
728x90