Re: a sharde member variable in base class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Armin Zingler (az.nospam_at_freenet.de)
Date: 06/15/04


Date: Tue, 15 Jun 2004 23:46:19 +0200


"John" <John@discussions.microsoft.com> schrieb
> Is this variable shared among all of the instances of the base class
> and derived classes?
>
> Class Person
> Shared Id as String
> Shared Function GetId() as String
> Return Id
> End Function
> End Class
>
> Class Emp1 : Inherits Person
> End Class
>
> Class Emp2 : Inherits Person
> End Class
> .
> .
> .
>
> Dim e1 as New Emp1
> Dim e2 as new Emp2
>
> 'Are e1 and e2 sharing the same id?

No, not e1 and e2 are sharing the same id, but *class* Person has exactly
one ID - even without e1 and e2.

-- 
Armin
How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Relevant Pages

  • Re: Inheritance and Interfaces
    ... Talk about having a "duh" moment. ... >You only need to implement INotifyPropertyChanged in the base class, ... > Public Property NameAs String ... >The Overridable Sub OnPropertyChanged allows derived classes to raise ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Inheritance question
    ... I do define the string in each of the derived classes as well as the base. ... defined in the base class, as you suggested, which works perfectly. ... impression that I was putting the keywords in the base class. ...
    (microsoft.public.dotnet.framework)
  • Re: Shadows and Overrides and Bears, Oh My!
    ... I have one method in the base class that all derived classes need to be able ... I also want to have other methods named Populate that have different ... DoMyPopulatin(MyObject as BaseObject, a as String) ... Public Shadows Sub Populate ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Shadows and Overrides and Bears, Oh My!
    ... I have one method in the base class that all derived classes need to be able ... I also want to have other methods named Populate that have different ... DoMyPopulatin(MyObject as BaseObject, a as String) ... Public Shadows Sub Populate ...
    (microsoft.public.dotnet.general)
  • Re: Inheriting a base class - Invalid Cast Exception
    ... The base class is just there to simplify most of the data access code, collection handling, and things like that. ... >string, while the Item>property in the DataCollection class takes an object, because I want to use>it for various tables, some that have numeric keys, and some that have>string keys. ... If I change the DataCollection item class to take a string key>, I then can do an OverRides property, but like you said,>that doesn't fix my problem. ...
    (microsoft.public.dotnet.languages.vb)