Giả sử mình có đoạn code
#include <iostream>
using namespace std;
class Sample
{
int point;
public:
Sample()
{
point = 5;
}
Sample operator++()
{
point++;
return *this;
}
void Display()
{
cout << point << endl;
}
};
int main()
{
Sample s;
++s;
// s++;
s.Display();
}
Tại sao phải là ++s thì nó mới chạy,còn s++ thì không được.