Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

inheritence quickie

Posted on 2006-07-24
4
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

721 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