Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2007

Tip: Looking for answers? Try searching our database.

oop question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
param@community.nospam - 07 Aug 2007 19:32 GMT
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!
Peter Duniho - 07 Aug 2007 19:41 GMT
> 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
[quoted text clipped - 5 lines]
> 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
param@community.nospam - 08 Aug 2007 02:26 GMT
That is pretty sweet! :) Thanks

>> Lets say I have a base class called BaseClass which has 2 methods
>> Method1() and Method2(). Also lets assume that Method1() has code that
[quoted text clipped - 14 lines]
>
> Pete
sloan - 07 Aug 2007 20:36 GMT
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)))

> Hello all,
>
[quoted text clipped - 11 lines]
>
> TIA!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.