Re: CMAP under vs2005+
Tommy wrote:
Martin T. wrote:
Note that std::map (as all std containers) does not have a virtual
destructor. (As opposed to CMap that is inheriting from CObject which
has a virt dtor).
>
So you should never use your CMapEx polymorphically!
Hi Martin,
I think I understand what you mean by this, but I am not sure.
Is this something the compiler will highlight? will it compile if I
tried use CMapEx polymorphically?
I'm an engineer, not a CS major so I learn by best by example :-)
Can you provide an practical example of what you mean by this? How
CMapEX should not be used?
I have it now as such:
class CMapEx : public std::map<TKEYSTR, VALUE, __cbCStringCaseCmp>
{
...
}
I believe this considered a polymorph of the std::map class. Is this
correct?
Read: [20.7] When should my destructor be virtual?
http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7
That means that you should never do:
[pseudocode]
CMapEx* pmex = new CMapEx;
std::map* pm = pmex;
....
delete pm; .. The dtor of CMapEx wont be called.
[/pseudocode]
Which you probably won't do anyway.
br,
Martin