Click here to Skip to main content
15,888,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ concept Pin
David Crow29-Apr-11 9:58
David Crow29-Apr-11 9:58 
GeneralRe: C++ concept Pin
jschell30-Apr-11 12:50
jschell30-Apr-11 12:50 
GeneralRe: C++ concept Pin
Niklas L29-Apr-11 11:00
Niklas L29-Apr-11 11:00 
AnswerRe: C++ concept Pin
«_Superman_»29-Apr-11 17:19
professional«_Superman_»29-Apr-11 17:19 
AnswerRe: C++ concept Pin
Stefan_Lang1-May-11 23:58
Stefan_Lang1-May-11 23:58 
You can, but you normally shouldn't. You'll destroy both the variables and the virtual function table (if you have one), so cannot access either. The only things you could still safely do is call static member functions or access static member variables.

That said...:

- What would happen if you allocated an array of objects of this type? -> crash!

- What would happen if you allocated the object on the stack, not on the heap? -> crash!

- What would happen if you allocated an object through malloc, a pool allocator, or any other non-standard memory allocator?
-> most likely crash

- What would happen if you allocated an object of a class derived from this one? -> might work, but could have undesired effects as you're calling the derived class' delete function which may do more than you intended

The only way to define such a class in a way that prevents any of the uses above is by protecting access to all the constructors and the destructor, and then provide create() and destroy() functions instead. Or use a friend helper class that does it for you (e. g. smart pointer or factory)
QuestionScroll bar in Listview Pin
TheHelenLee28-Apr-11 20:07
TheHelenLee28-Apr-11 20:07 
AnswerRe: Scroll bar in Listview Pin
Hans Dietrich28-Apr-11 21:46
mentorHans Dietrich28-Apr-11 21:46 
GeneralRe: Scroll bar in Listview Pin
Niklas L28-Apr-11 21:55
Niklas L28-Apr-11 21:55 
AnswerRe: Scroll bar in Listview Pin
Hans Dietrich28-Apr-11 21:56
mentorHans Dietrich28-Apr-11 21:56 
GeneralRe: Scroll bar in Listview [modified] Pin
Niklas L28-Apr-11 22:18
Niklas L28-Apr-11 22:18 
AnswerRe: Scroll bar in Listview Pin
Hans Dietrich29-Apr-11 0:31
mentorHans Dietrich29-Apr-11 0:31 
QuestionRe: Scroll bar in Listview Pin
Niklas L29-Apr-11 0:50
Niklas L29-Apr-11 0:50 
AnswerRe: Scroll bar in Listview Pin
Hans Dietrich29-Apr-11 4:21
mentorHans Dietrich29-Apr-11 4:21 
GeneralRe: Scroll bar in Listview Pin
TheHelenLee28-Apr-11 23:52
TheHelenLee28-Apr-11 23:52 
AnswerRe: Scroll bar in Listview Pin
Hans Dietrich29-Apr-11 0:19
mentorHans Dietrich29-Apr-11 0:19 
GeneralRe: Scroll bar in Listview Pin
TheHelenLee29-Apr-11 22:13
TheHelenLee29-Apr-11 22:13 
QuestionADO recordset moveNext abnormal Pin
Jokcy28-Apr-11 16:58
Jokcy28-Apr-11 16:58 
AnswerRe: ADO recordset moveNext abnormal Pin
barneyman28-Apr-11 18:57
barneyman28-Apr-11 18:57 
GeneralRe: ADO recordset moveNext abnormal Pin
Jokcy28-Apr-11 19:08
Jokcy28-Apr-11 19:08 
GeneralRe: ADO recordset moveNext abnormal Pin
barneyman28-Apr-11 19:21
barneyman28-Apr-11 19:21 
GeneralRe: ADO recordset moveNext abnormal Pin
Jokcy29-Apr-11 4:29
Jokcy29-Apr-11 4:29 
GeneralRe: ADO recordset moveNext abnormal Pin
barneyman29-Apr-11 17:13
barneyman29-Apr-11 17:13 
GeneralRe: ADO recordset moveNext abnormal Pin
Jokcy30-Apr-11 4:40
Jokcy30-Apr-11 4:40 
QuestionWriting to the console only (without re-direction) Pin
Member 385202428-Apr-11 12:00
Member 385202428-Apr-11 12:00 
AnswerRe: Writing to the console only (without re-direction) Pin
Hans Dietrich28-Apr-11 12:09
mentorHans Dietrich28-Apr-11 12:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.