Re: why no struct inheritance?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Paul Werkowitz <newsgroups@xxxxxxxxxxxxxxxx> wrote:

<snip>

Note that we have value types, not reference types. That means: it all
depends on the definition of the assignment operator. Since we cannot
overload the assignment operator, your statement is illegal for any user
defined structs Point and ExtendedPoint.

No argument against derivation of structs.

So there'd be no polymorphism possible... sounds like a good argument
against derivation of structs to me. I wouldn't be able to pass an
ExtendedPoint to a method requiring a Point, contrary to all normal
expectations. To not have a conversion available from a derived type to
the base type seems very odd to me.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: why no struct inheritance?
    ... If this would compile, the expected behavior is ... an object ob type ExtendedPoint is created (memory allocated + fully ... depends on the definition of the assignment operator. ... No argument against derivation of structs. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: malloc vs new for POD types
    ... You don't update the reference count if you blindly copy ... constructor and assignment operator. ... purpose is to do something important if the object is copied or assigned. ...
    (comp.lang.cpp)
  • Re: The void** pointer breaking symmetry?
    ... in Msg. ... Funny! ... I never realized that the assignment operator works with structs. ...
    (comp.lang.c)
  • Re: Derived types with allocatable arrays; more problems
    ... If a derived type in this case) contains an allocatable array, ... You'd better define your own assignment operator. ...
    (comp.lang.fortran)