Re: Class and Inheritance
On 2007-08-04 12:06, Jam wrote:
Hello All,
Your comment is needed on following subject,i define the Class and
Inheritance as following,what do you think?
Are you trying to come up with a definition of the concepts of class and
inheritance? If so, you are better of looking it up (you can find it all
over the net) than trying to get it right yourself.
Class: Class is a set of objects which shares common states and
behaviors,
What do you mean share? Do all objects belonging to a class have share
the state or what?
Class can contain subclasses.
Contain as in having them as members, if so what is a subclass?
Inheritance: if two classes are having two common states and behaviors
or if a class is derived from another class it is called Inheritance,
No, you can have two classes with identical states and behaviour without
any relationship between them. If a class is derived from another it has
inherited from it (that's the definition of inheritance).
All's comment is needed,is this defination ok or something more should
be here....?
A class is an abstract conceptual description of a type of objects, so
the class Car is an abstract description that can be applied to all cars
(at least all cars in the problem domain). A subclass is a more specific
abstraction of a subset of the class it derives from, so the class
electricCar is a subclass of Car, and gives a more detailed description
of electric cars, which are a subset of all cars.
--
Erik Wikstr?m