如何在 C++ 中定义一侧运算符?

How to define one side operators in c++?

如何在 C++ 中定义像 ++-- 这样的一侧运算符?

例如我们要定义a##(a % 45) + 2 [这只是一个例子]

operator ++()(前缀递增运算符)
operator ++(int)(后缀递增运算符)

operator -- 相同。

class Example
{
public:
   int a = 0;

   Example& operator++() { a = (a % 45) + 2; return *this; } // ++ex;
   Exampleoperator++(int) { Example tmp = *this; ++(*this); return tmp; } // ex++;
};

没有operator ##.