High Quality
Open the downloaded document, and select print from the file menu (PDF reader required).
The concept of class is similar to the concept of structure in C. In other words classes are
the data types on which objects are created. So while a class is created no memory is
allocated only when an object is created memory gets allocated.
As the name suggests Inheritance is the process of forming a new class from an existing
class that is from the existing class called as base class, new class is formed called as
derived class. This is a very important concept of object oriented programming since this
feature helps to reduce the code size.
By this feature of object oriented programming it is possible to represent the needed
information in program without presenting the details. Also by the feature of data
abstraction it is possible to create user defined data types and thus increase the power of
programming language.
Data Encapsulation is the process of combining data and functions into a single unit
called class. By this method one cannot access the data directly. Data is accessible only
through the functions present inside the class. Thus Data Encapsulation gave rise to the
important concept of data hiding.
The ability to use an operator or function in different ways in other words giving different
meaning or functions to the operators or functions is called polymorphism. Poly refers
many. That is a single function or an operator functioning in many ways different upon
the usage is called polymorphism.
An object is a software bundle of related state and behavior.
Software objects are often used to model the real-world objects that you find in everyday
life. Real-world objects share two characteristics: They all have state and behavior.
Software objects are conceptually similar to real-world objects:
they too consist of state and related behavior.
An object stores its state in fields (variables in some programming languages)
and exposes its behavior through methods (functions in some programming languages).
An interface is a contract between a class and the outside world.
When a class implements an interface, it promises to provide the behavior published by
that interface.
That is object oriented programming has the feature of allowing an existing class which is written and debugged to be used by other programmers and there by provides a great time saving and also code efficiency to the language. Also it is possible to a have the existing class and adds new features to the existing class as pet the programmer’s choice.
Thus the object oriented programming features helps the program ad there by users of the application to achieve increased performance, it saves time of developing the application, give optimized code for the application, helps in gaining secured applications and there by helps in easier maintenance.
//program to read employee details and to output the data Comment
#include < iostream.h > Preprocessor Statement
class employee Class Declaration
{private:
public:
void getvalue()
{cout< < ”INPUT EMP NAME:”;
cint > >empname;
cout< < ”INPUT EMP NO:”;
cint > >empno;
}void displayvalue()
}
};
main()
{employee e1; Creation of Object
A class in C++ is an encapsulation of data members and functions that manipulate the data. The class can also have some other important members which are architecturally important.
Add a Comment