Solved

inheritence quickie

Posted on 2006-07-24
4
218 Views
Last Modified: 2010-04-16
hi

i have an abstract base class "Base1.cs"

i have another concrete class "Organisation.cs" that inherits "Base1.cs"  Organisation : Base1

i have other classes that use Organisation.cs.

i want those classes that use Organisation.cs to be able to use "Base1.cs" methods but only via Organisation.cs.

What is the most appropriate scope i should give the methods on Base1.cs.

public ?  (this seems abit too general?)

thanks v much.

p.s - i know it cant be protected.


 
0
Comment
Question by:MrKevorkian
4 Comments
 

Expert Comment

by:muskok
Comment Utility
You have to make the methods in Base1 protected and provide public methods in Organisation class. These public methods will call Base1's protected methods.
0
 
LVL 23

Expert Comment

by:apresto
Comment Utility
Hi MrKevorkian,

You could created some Protected Properties in the Organisation class then anything that inherits Organsiation will be able to see those properties, which inturn look at inherited members from Base1

Apresto
0
 
LVL 13

Accepted Solution

by:
devsolns earned 400 total points
Comment Utility
I would NOT recommend using protected scope.  In true OOP you should be able to do just fine without.  You state that you want derived classes to be able to use base1 methods but only by going through Organisation.  This is happening already because you made Base1 abstract.  No one will be able to instantiate that object and access its methods directly, only classes derived from that Base1 class can do so.  You'll also be missing out of many advantages of polymorphism and therefor questioning the use of inheritance here.

There are some good uses for protected accessibilty.  For example your event invoker methods.  You dont want to make them public but certainly want to provider accessibility for your derived classes to invoke directly so protected works.

Take care,
gp
0
 
LVL 1

Author Comment

by:MrKevorkian
Comment Utility
i have decided to leave them public.  
i thought there might be another key word that was more suitable, but if there isnt thats fine.
i didnt really want to put extra properties on organisation.cs

thanks everyone.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now