Why is “operator bool()” invoked when I cast to “long”?

后端 未结 3 434

I have the following class:

class MyClass {
public:
   MyClass( char* what ) : controlled( what ) {}
   ~MyClass() { delete[] controlled; }
   operator char*() c         


        
3条回答
  •  离开以前
    2021-01-22 00:27

    You cannot implicitly cast a T* to long. But you can cast a bool to long.

    So the operator bool is used.

    You have to define a operator LPARAM.

提交回复
热议问题