Object Oriented Programming (OOP) and Classes in C++


Object Oriented Programming (OOP) and Classes.

Object oriented programming was developed because limitations were discovered in earlier approaches to programming , to see what are these limlitations are we need to understand these limitations.c++ is a object oriented programming while c language is procedural language. c++ is a superset of c.
Characteristics of Object oriented programming.
1. Objects
     Objects consists of data members and functions that act on data.
2. Class
     Class is simply a blueprint.
    it has no existence.
3. Inheritance
inheritence is a process of creating new classes from existing classes.
existing class is a base class (parent) and new class is a derived class (child class).
4. Reusability.
 Once a class has been written ,created and debugged  it can be distributed to other programmers for use in their own programms. This is called resuability.
5. Polymorphism
Using operators or functions in a different ways ,depending on what they are operating on is called polymorphism.
Polymorphism also means one thing with several distinct form.
6. Overloading
when and existing operator gives the capability to operate on a new data type it  is called overloading.
Giving new meanings to existing c++ operators.
Readabiliy increases
7.Data hiding
Data hiding means if data is hidden so it is safe from any accidental change.Protecting data from unathorized access.
Class description
A class is a data type that you define. It can contain data elements, which can either be variables of the basic types in C++ or other user-defined types. The data elements of a class may be single data elements, arrays, pointers, arrays of pointers of almost any kind or objects of other classes, so you have a lot of flexibility in what you can include in your data type. A class can also contain functions which operate on objects of the class by accessing the data elements that they include. So, a class combines both the definition of the elementary data that makes up an object and the means of manipulating the data belonging to individual instances of the class.
The data and functions within a class are called members of the class. Funnily enough, the members of a class that are data items are called data members and the members that are functions are called function members or member functions. The member functions of a class are also sometimes referred to as methods, although we will not be using this term.
When you define a class, you define a blueprint for a data type. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. It's much the same as if you wrote a description of the basic type double. This wouldn't be an actual variable of type double, but a definition of how it's made up and how it operates. To create a variable, you need to use a declaration statement. It's exactly the same with classes, as you will see


1.A class is a user-defined data type

2.Object-oriented programming is the programming style based on the idea of defining your own data types as classes

3.Declaring an object of a class is sometimes referred to as instantiation because you are creating an instance of a class

4.Instances of a class are referred to as objects

5.The idea of an object containing the data implicit in its definition, together with the functions that operate on that data, is referred to as encapsulation.
Easy definition is  
Encapsulation means, the packaging of data members and its functions in a closed unit is called encapsulation.

C++ and C language difference

C++ is derived from c language. c++ is a superset of c.Almost every correct statement in c is also correct in c++ , although reverse is not true.c++ was origonally called  ,c with classes. c++ means increment in c language or adding new features in c language.
c++ program is similar to c program but organizational principles are different.Most lines of progam code are the same in c and c++.