DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 7 Aug 2007 13:32:36 -0500,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    am
          2    Peter Duniho
                 3    am
          4    sloan


oop question   
Hello all,

I have a question related to object oriented programming as follows:-

Lets say I have a base class called BaseClass which has 2 methods Method1() 
and Method2(). Also lets assume that Method1() has code that invokes 
Method2()

Now lets say a new class called InheritedClass inherits BaseClass and 
overrides Method2()

If I call InheritedClass.Method1() the which Method2() code will fire? The 
one contained in BaseClass or the one contained in InheritedClass?

TIA!
Date:Tue, 7 Aug 2007 13:32:36 -0500   Author:  

Re: oop question   
param@community.nospam wrote:

> Lets say I have a base class called BaseClass which has 2 methods Method1() 
> and Method2(). Also lets assume that Method1() has code that invokes 
> Method2()
> 
> Now lets say a new class called InheritedClass inherits BaseClass and 
> overrides Method2()
> 
> If I call InheritedClass.Method1() the which Method2() code will fire? The 
> one contained in BaseClass or the one contained in InheritedClass?


Assuming that Method2() is truly virtual, and thus can be truly 
overridden, then for an instance of InheritedClass, 
InheritedClass.Method2() will always be executed, even when called from 
BaseClass.Method1().

That is, in fact, the point of virtual methods.

Pete
Date:Tue, 07 Aug 2007 11:41:41 -0700   Author:  

Re: oop question   
Look at this design pattern as well.

http://www.dofactory.com/Patterns/PatternTemplate.aspx

As earlier said, "that is the point".  ((<< not being a smart butt, but 
yeah, that's kind of the kit and ka-boodle with it)))


<param@community.nospam> wrote in message 
news:%23omGaFS2HHA.5772@TK2MSFTNGP02.phx.gbl...

> Hello all,
>
> I have a question related to object oriented programming as follows:-
>
> Lets say I have a base class called BaseClass which has 2 methods 
> Method1() and Method2(). Also lets assume that Method1() has code that 
> invokes Method2()
>
> Now lets say a new class called InheritedClass inherits BaseClass and 
> overrides Method2()
>
> If I call InheritedClass.Method1() the which Method2() code will fire? The 
> one contained in BaseClass or the one contained in InheritedClass?
>
> TIA!
> 
Date:Tue, 7 Aug 2007 15:36:12 -0400   Author:  

Re: oop question   
That is pretty sweet! :) Thanks

"Peter Duniho"  wrote in message 
news:13bhf76i9g8maac@corp.supernews.com...

> param@community.nospam wrote:
>> Lets say I have a base class called BaseClass which has 2 methods 
>> Method1() and Method2(). Also lets assume that Method1() has code that 
>> invokes Method2()
>>
>> Now lets say a new class called InheritedClass inherits BaseClass and 
>> overrides Method2()
>>
>> If I call InheritedClass.Method1() the which Method2() code will fire? 
>> The one contained in BaseClass or the one contained in InheritedClass?
>
> Assuming that Method2() is truly virtual, and thus can be truly 
> overridden, then for an instance of InheritedClass, 
> InheritedClass.Method2() will always be executed, even when called from 
> BaseClass.Method1().
>
> That is, in fact, the point of virtual methods.
>
> Pete 
Date:Tue, 7 Aug 2007 20:26:34 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us