about C++
-
Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,
-
Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,
Chau Ngoc Vo wrote: about C++ Um... a question about C++ in the C++ forum, who would have thought ? You'll get more readers if you actually say something in your headers. Chau Ngoc Vo wrote: I said that no body do at that. But he said it is used a lot of in MFC. Did either of you think to actually type this into a compiler and see what it spits back ? Your friend is right. If it's used in MFC or not, I don't know. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,
It's often used in MFC and ATL where instances are stored in a OS objects that have no knowledge of C++. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,
It's used in CFrameWnd in PostNcDestroy. CFrameWnds should always be created with new, so it can call "delete this" as the last thing it does before the window is gone.
-
Dear all, I have a quarrel with my friend as bellow: In object oriented programming we declare a class: class CAA { public: CAA(); void DelMyself() { delete this; } private: virtual ~CAA(); } I said that no body do at that. But he said it is used a lot of in MFC. in this situation you only declared pointer of class CAA not declare a object. Please give some comemnt. Thanks a lot,
Another example of delete self is in modeless dialog box. modeless dialog boxes delete themself The World is getting smaller and so are the people.