Class and Inheritance

J

Jam

Hello All,
Your comment is needed on following subject,i define the Class and
Inheritance as following,what do you think?

Class: Class is a set of objects which shares common states and
behaviors,Class can contain subclasses.
Inheritance: if two classes are having two common states and behaviors
or if a class is derived from another class it is called Inheritance,

All's comment is needed,is this defination ok or something more should
be here....?

With Kind Regards,
Jameel Sameemi
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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.
 
O

osmium

Jam said:
Your comment is needed on following subject,i define the Class and
Inheritance as following,what do you think?

Class: Class is a set of objects which shares common states and
behaviors,Class can contain subclasses.
Inheritance: if two classes are having two common states and behaviors
or if a class is derived from another class it is called Inheritance,

All's comment is needed,is this defination ok or something more should
be here....?

I don't like it at all. There is too much muddling of classes and objects.
I would not use the word "set" if I could avoid it, it may lead to undesired
inferrences, is there a problem with "group"? .
 
J

Jerry Coffin

[ ... ]
Class: Class is a set of objects which shares common states and
behaviors,Class can contain subclasses.

This simply isn't correct -- a class is NOT a set (or group, or anything
else) of objects. Rather, a class defines some state and behavior. You
can then 1) define objects of that class, or 2) define other classes
that inherit from the first class. In most cases, a particular class is
meant for one use or the other, but not both.
Inheritance: if two classes are having two common states and behaviors
or if a class is derived from another class it is called Inheritance,

Inheritance is a way for two (or more) classes to share common state
and/or behavior, there are also other ways for classes to share common
state/behavior -- for example, two classes can each embed an obect of a
third class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,328
Latest member
66Teonna9

Latest Threads

Top