By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,152 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,152 IT Pros & Developers. It's quick & easy.

partial inheritance?

P: 6
Approaching to build the framework for safe programming.

Can the business objects be partially inherited ,in

Please help me to get an insight on.

Jan 22 '13 #1
Share this Question
Share on Google+
4 Replies

Expert Mod 5K+
P: 9,731
I think you may be confusing inheritance with "partial class"?

I don't think I've ever heard of partial inheritance.

What I would do is break up your inheritance structure so that it makes sense...

So that your base objects contain only the things that you want to be inherited.

For example if you had:
  • cars
  • vans
  • pick up trucks
  • motorcycles

I would create a "vehicle" class that has:
  • wheels
  • engine

I would have my "motorcycle" class inherit from the "vehicle" class so that it can add it's own custom properties to it:
  • handle bars
  • throttle
  • hand break

I could also create an "automobile" class that inherits from "vehicle" and add custom properties to it:
  • steering wheel
  • break peddle
  • gas peddle

Now my "car","pick up truck", and "van" classes can inherit from "automobile" and add their own unique properties to their classes. These classes will have all of the "vehicle" and "automobile" properties along with their own properties....

And the "motorcycle" class will have have all of the "vehicle" properties but not the "automobile" properties...

In this way the motorcycle class inherits only a "partial" amount of properties that the van class inherits simply because motorcycle inherits directly from the vehicle class while the van class inherits from the automobile class which inherits from the vehicle class.

Jan 22 '13 #2

P: 6
Thank you for the reply.

With an insight you've given, code reusability may hamper.

Even I didn't hear of 'partial inheritance' in dotnet framework,ever.

Actually, I wanted to get an implementation idea for what it is called as
'partial inheritance'. To my knowledge , it can be - partial and limited or conditional access to the base class's operations and it's implementation.

I hope this isn't an absurd thought to think over.

Help please.
Jan 24 '13 #3

Expert Mod 5K+
P: 9,731
There are scope modifiers...also called access modifiers (like private, protected, public etc.) to help restrict access to functionality in the base class.

So, if you declare a "protected" function in your base class, any class that inherits from that class can use the function but the function will not be accessible to any other calling code.

Jan 24 '13 #4

P: 293
I heard of Partial Inheritance in Python.. I didn't ever work out with Python, however.

You may get an idea to build a framework.

Hope this helps.
Jan 29 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.