Вы находитесь на странице: 1из 14

Concept about C++:

C++ is an enhanced version of the C language.


C++ includes everything that is part of C language and
adds support for object oriented programming (OOP).
With very few, very major exceptions,
C++ is a superset of C.
procedure oriented programming
Conventional programming, using high level languages such
as COBOL, FORTRAN and C, is commonly known as procedure-
oriented programming (POP).
In the procedure-oriented approach, the problem is viewed as
a sequence of things to be done such as reading, calculating
and printing. 1
A number of functions are written to accomplish these tasks

Main characteristics of procedure-oriented programming are:


Large programs are divided into smaller programs known as
functions.
Most of the functions share global data.
Data move openly around the system from function to
function.
Functions transform data from one form to another.
The main focus of POP is on “how to get the task done” it
follows the flow chart to get the task done. OOP’s main focus
is on data security as only the objects of a class are allowed to
access the attributes or function of a class.

2
object-oriented programming
Object Oriented Programming is a programming in which we
design and develop our application or program based of object.
Objects are instances(variables) of class.
Object oriented programming does not allow data to flow freely
around the system.
Striking features of object-oriented programming are:
1 Programs are divided into what are known as objects.
2 Data structures are designed such that they characterize the
objects.
3 Functions that operate on the data of an object are tied
together in the data structure.
4 Data is hidden and cannot be accessed by external functions.
5 Objects may communicate with each other through functions.
3
What are the advantages of OOP?
It presents a simple, clear and easy to maintain structure.
It enhances program modularity (partitioning) since each object exists
independently.
New features can be easily added without disturbing the existing one.
Objects can be reused in other program.
Data is fully secured
Operator overloading is possible in OOP
Various elements of OOP are:
Object
Class
Method
Encapsulation
Information Hiding
Inheritance
Polymorphism
4
Procedure Oriented Programming Object Oriented Programming

1. In POP, program is divided into 1. OOP, program is divided into


small parts called functions. parts called objects.
2. POP follows Top Down 2. OOP follows Bottom Up
approach. approach
3. POP does not have any access 3. OOP has access specifiers
specifier. named Public, Private,
4. To add new data and function Protected, etc
in POP is not so easy. 4. OOP provides an easy way to
5. Example of POP are : C, VB, add new data and function
FORTRAN, Pascal. 5. Example of OOP are : C++,
JAVA, VB.NET, C#.NET

5
In C programming language, we are using printf() function
for output operation and scanf() function for input
operation. But in C++, cout<< is using for output operation
and cin>> function is using for input operation. “<<”
operator is called insertion or put to operator . “>>”
operator is called extraction or get from operator.

6
C++ Comments
In C++, we can include comments in our program two different
ways such as-
For multiline comments, began a comment with /* and end it with
*/
For single line comments, began a comment with // and stop at
the end of the line.
C++ advantage
C++ is a highly portable language and is often the language of
selection for multi-device, multi-platform app development.
C++ is an object-oriented programming language and includes
concepts like classes, inheritance, polymorphism, data abstraction.
C++ use multi-paradigm programming.
C++ gives the user complete control over memory management.
C++ has a huge community around it.
7
Class: A class in C++ is the building block, that leads to
Object-Oriented programming. It is a user-defined data
type, which holds its own data members and member
functions, which can be accessed and used by creating an
instance of that class. A C++ class is like a blueprint for an
object.
An Object is an instance of a Class. This is the basic unit that
are associated with the data and methods of a class. To
access any element of a class, an object is used.
Method
A set of programming code used to perform the operation
of the program. For example, find_salary().
 
8
Specifying a class:
Generally, a class specification has two parts:
Class declaration
Class function definition
The general form of a class declaration is:
class class_name
{
private:
variable declarations;
function declarations;
 
public:
variable declarations;
function declarations;
};

9
Accessing class members:
Syntax:
object_name.function_name(argument_list);
 example:
ob.getdata();
ob.display();
Defining member function:
Member functions can be defined in two places:
Outside the class definition
Inside the class definition
 Outside the class definition:
Member functions that are declared inside a class have to define
separately outside the class. return_type class_name ::
function_name (argument declaration)
{
Function body
}
10
Inside the class definition:
We can define member functions inside the class as well. Only
small functions are defined inside the class.
class ae
{
public:
int x;
void getdata()
{
x=10;
}
void display()
{
cout<<x;
}
};
11
Public:- If a class member is public, it can be used anywhere
without the access restrictions.
Private: if a class member is private, it can be used only by
the members and friends of class.
Protected : if a class member is protected, it can be used only
by the members of class, friends of class and derived class.
What is encapsulation?
The process of binding the data and the functions acting on
the data together in an entity (class) called as encapsulation.
What is inheritance?
Inheritance is the process of acquiring the properties of the
exiting class into the new class. The existing class is called as
base/parent class and the inherited class is called as
derived/child class.
12
Polymorphism:
Polymorphism is the ability to calls the same named methods
from different classes
automatic inline function If a member function's definition is
short enough, the definition can be included inside the class
declaration. This kind of function is called automatic inline
function
OOP treats data as a critical element in the program
development and does not allow it to flow freely around the
system. It ties data more closely to the functions that operate
on it, and protects it from accidental modification from
outside functions.

13
C++ used the bottom-up approach for project development.
In this approach, bottom level modules developed first (Lower
level module developed, tested and debugged). Then the next
module developed, tested and debugged. This process is
continued until all modules have been completed.

Top down In this approach, a large project divides into small


programs, and these programs are known as modules. The
basic task of a top-down approach is to divide the problem
into tasks and then divide tasks into smaller sub-tasks and so
on.

14

Вам также может понравиться