I am working on an assignment, and I think I made myself lost thinking too much....
I know a class is an object. It has certain properties. I created 2 derived classes from it, these 2 dervived classes also have properties, but with more properties. From those 2 derivived classes stem 2 more classes.
Long story short... I'm not sure if I'm using public properties, functions correctly.. If the 2 derived classes from the derived class of a class, how do I pass my 3rd derived class to the base class. Properties are set value to variable of a class, but how do i recall the value to the main?... I don't know if anyone can understand what I'm saying, but bassically, I want to get the info from the most derivived class to base class.
3 Replies - 716 Views - Last Post: 01 April 2012 - 03:20 PM
#1
Can someone help me simply how class and class inheritance works?
Posted 29 March 2012 - 05:51 PM
Replies To: Can someone help me simply how class and class inheritance works?
#2
Re: Can someone help me simply how class and class inheritance works?
Posted 29 March 2012 - 06:00 PM
AdamSpeight2008 has a good tutorial on Inheritance - it's sure to help you out!
This post has been edited by DimitriV: 29 March 2012 - 06:01 PM
#3
Re: Can someone help me simply how class and class inheritance works?
Posted 30 March 2012 - 07:01 AM
Quote
I want to get the info from the most derivived class to base class.
I'm not sure what you mean by this. Classes don't typically contain data, unless you're thinking of static fields, and objects only share information via the methods you write for them.
Can you give me a f'rinstance? What is it you're trying to accomplish here?
Maybe you can do it in terms of the good old Animal hierarchy:
Base class is Animal
Vertebrate and Invertebrate extend Animal
Mammal, Bird, and Reptile extend vertebrate / Insect and Mollusk extend Invertebrate
Human and Squirrel extend Mammal, Whelk extends Mollusk (fill in more species as needed
jon is an instance of Human, and lawrence is an instance of Whelk. (sorry...)
Given that hierarchy, what is it you'd like to be able to do?
This post has been edited by jon.kiparsky: 30 March 2012 - 07:02 AM
#4
Re: Can someone help me simply how class and class inheritance works?
Posted 01 April 2012 - 03:20 PM
*Moved to Software Development*
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|