Here is the code,
When I use cast operator defined in class A, should I use statement #1 or #2? BTW, they both compile. Thanks.Code:class B { }; class A { public: operator B*() { B* pB = new B; return pB; } }; int main() { A a; B* pB = (B*)a; // #1 B* pB = static_cast<B*> (a); // #2 return 0; }




Reply With Quote