Vic Wagner <[EMAIL PROTECTED]> wrote:
> Ananth wrote:
>  > Scott Meyers (and the standard) clearly instruct not to treat arrays
>  > polymorphically in C++.
>  > Because compiler has no means of finding out whether heap objects
>  > pointed by base class pointers are base class objects or derived class
>  > objects. Program will bomb when deleting array of base class pointers
>  > pointing to derived class objects.
>  >
>  > I understand his advise, makes perfect sense, no issues there.
>  > But MSVC doesn't comply to Scott's advise: deleting an array of base
>  > class pointers pointing to derived class objects works perfectly fine
>  > in MSVC. But bombs in other popular compilers.
>  >
>  > I'm not bothered about porting in my project, its all MFC code anyway,
>  > so porting is a non-issue. Any reasons why I should follow Scott's
>  > advise "for my\any projcet in MFC\MSVC"?
>  > I googled on this topic and found few threads. They talk about same
>  > thing: works on MSVC, bombs on other compilers.
>  > But could not find a thread on why I shouldn't treat array
>  > polymorphically in MSVC. The only reason I could think of is to fall
>  > into the trap of thinking MSVC behavior is also available on other
>  > compilers, I'll face issues when using some other compiler.
>  > But as long as I keep that in some corner of my mind, I see no reason
>  > why arrays should not be treated polymorphically when using MSVC.
>  >
>  > Please let me know your thoughts.
>  >
>  > Cheers
>  > - Ananth
>  >
>  Do what you want, but I can guarantee you won't remember this is a
>  possible problem
>  why are you using arrays anyhow??

No, I'm not using above array code in my professional programs. It was
like a college assignment: wanted to try out and see how the code
described in Scott Meyer's book bombs, so wrote a test program. But to
my surprise it ran perfectly well in MSVC.

Cheers
- Ananth

Reply via email to