Tuesday, December 7, 2010

Introduction to Class

Class:
class is a real world entity.
class contains its own data members and function members.
class is a data type, we can create a variable of a class type.
class is a instance of variables.
class is a logical construct.

syntax:
class class_name
{
access specifier:
datamembers declaratrions;
function member declaarations;
class body;
} object list;

The above syntax is for c++

for java the syntax is as follows:

syntax:
class class_name
{
access specifier:
datamembers declaratrions;
function member declaarations;
class body;
}

the syntax diffecence between c++ and java is semicolon(;) is not expected at the end of the class, while in c++ it is expected. Because in c++ the structure of the class is similar to that of 'Structres'. Here 'class' is a keyword.

Example in java:
class Student
{
char name[30];
int reg_no;
void get_details;
void display_details;
}

No comments:

Post a Comment