Re: Statics and inheritance

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Well, if you declare it in Root then you are implying that ALL the derived
classes share the very same value.
If you happen to have the same escenario on each of the derived classes,
then you would have to do the same thing on each one, remember each of them
happen independely of the others.

Not very complicated to do in any case.



cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Andrew Ducker" <andrew@xxxxxxxxxxxxx> wrote in message
news:1117542594.968323.298590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Let's say I have a root class called RootBusinessService
> and I then want to have 25 business service classes based off of it.
>
> And each class has a property that's shared between all instances of it
> - called 'State'. I therefore want all of them to have a static
> property State.
>
> However, I can't declare this static property in RootBusinessService -
> because if I do, the subclasses will all point to that single property.
>
> So I have to declare it in each individual class. 25 times.
>
> Not only that, but if I want it to come up in intellisense for all
> subclasses of RootBusinessServer, I need to create a get/set in the
> root, and override it in each subclass to point to the 'local' static
> property.
>
> Is this right, or am I missing a really easy way to have a static
> property automatically exist in all subclasses of a given class?
>
> Cheers,
>
> Andy D
>


.



Relevant Pages

  • Re: Statics and inheritance
    ... >Let's say I have a root class called RootBusinessService ... >property State. ... I can't declare this static property in RootBusinessService - ... the subclasses will all point to that single property. ...
    (microsoft.public.dotnet.languages.csharp)
  • Statics and inheritance
    ... Let's say I have a root class called RootBusinessService ... the subclasses will all point to that single property. ... So I have to declare it in each individual class. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Learning tagged types
    ... Proc: Proc_Ptr; ... I think what you want is to declare a root type instead of Proc_Def. ... ("overriding" is an Ada 2005 extension; ...
    (comp.lang.ada)
  • Re: XML DTD Validation, namespaces and best practices
    ... >In my instance, to declare the namespace, I have this on my root ... You don't have to declare them on the root, ... namespace declaration attributes have to be declared like any others. ... >Since the validator says this is OK, I'm using what I've done is OK? ...
    (comp.text.xml)
  • Defining many classes in a single file
    ... And one can declare just as many in a header file. ... and subclasses, since certain ones of the subclass would require some very ... I intend that this system of "Shapes" would be ...
    (comp.lang.cpp)