Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

inheritence quickie

Posted on 2006-07-24
4
Medium Priority
?
270 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
ID: 17167753
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
ID: 17167767
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 1600 total points
ID: 17168052
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
ID: 17168117
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

927 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