Class-
Class is a collection of data members and member methods.
Object-
Object provides the communication between main body and class body.
Syntax for object creation-
Class_name <object_name> = new class_name();
<object_name>.data_member;// variables can be accessed.
<object_name>.method();// methods can be accessed.
See the example- Example for Classes and objects
In this example we used different methods for different classes, that seems too much useless coding. here the solution -
Comments
Post a Comment