Try it.
#include <iostream>
using namespace std;
class intwrapaer
{
public:
intwrapaer(int x):val(x){}
operator int ();
void print();
int operator ++(int);
private:
int val;
};
int intwrapaer::operator ++ (int)
{
return val++;
}
intwrapaer::operator int()
{
return val;
}
int main()
{
intwrapaer ivalue(3.7);
cout << ivalue << endl;
int d = ivalue++;
cout << d << endl;
cout << ivalue << endl;
system("PAUSE");
return 0;
}
補充說明:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.231.68.43
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.71.218.214