Академический Документы
Профессиональный Документы
Культура Документы
Introduction
About C++
C++ is based on the C language, and it was developed in
early 1980's by Bjarne Stroustrup at AT&T Bell Laboratories,
Here "++" use for the extension because "++" is a syntactic
construct used in C to increment a variable. Most of the C++
content is the super-set of "C", Due to this extension most C
programs can be compiled using a C++ compiler.
Object
Data abstraction
Defnition- The act of representing essential features
without including the background details or explanations.
Data abstraction defnes an abstract data type (ADT) by
designing a class.
Classes uses the concept of abstraction and are defned list
of abstract attributes.
The attributes are sometime called as data members
because they hold information.
The function that operates on these data are sometimes
called methods or member function.
Therefore data abstraction is:
Essential features of an object.
Distinguishes it from other kinds of objects.
Provides well–defned conceptual boundaries.
Encapsulation and Data hiding
Defnition :- The wrapping up of data and functions into a
single unit.
Data encapsulation is the most striking feature of class.
Encapsulation means that some or all of an object's internal
structure is "hidden" from the outside world.
The data is accessible only through the functions. Otherwise
it remains hidden from users. This insulation of data from
direct access by the program is called data hiding or
information hiding
Class Method: An operation required for an object or entity
when coded in a class is called a method.
Inheritance
Inheritance is a process by which objects inherit the
properties of another object belonging to another class
You can create new classes that extend or are descendent's
of existing classes. The descendant or derived classes can
inherit all the attributes of the original (or parent) class or
they can override some attributes
Polymorphism
A Greek term, means the ability to take more than on
form. An operation may exhibit diferent behavior is
diferent instances. The behavior depends upon the types
of data used in the operation.
It is the ability of objects of diferent types to respond
to functions of the same name.
Polymorphism in C++ is accomplished with the help of
Virtual functions.
Dynamic binding
Binding refers to the process of resolving the function to
be associated with the function call. There are two types
of binding:
Static binding
Dynamic binding
Static Binding is the binding that takes place during
compilation. It is also known as early binding or compile-
time binding.
Dynamic Binding or late binding means that the code
associated with a given function call is not known until
run–time. Since the function is linked with a class much
later after compilation, it is known as late binding or run-
time binding.
Message Communication
An object–oriented program contains a set of objects which
can communicate with each other.
The steps involved in writing an object–oriented program
are:
creating classes
creating objects from the classes defned and
Establishing communication between objects.
Objects communicate with each other by sending and
receiving messages.
A message in nothing but execution of a procedure.
Message communication involves specifying the name of
the object, name of the function and the information to be
sent.
Creating new data types and
Re-usability
One of the benefts of objects is that they give the
programmer a convenient way to construct new data types.
Object-oriented technology allows re-usability of the
classes by extending them to other classes using
inheritance.
Once a class is created and tested and ready to use, it can
be distributed to other programmers for using in their own
programs. This is known as re-usability
ADVANTAGES OF OOP's
l
Object-oriented programs can be comfortably upgraded.
Using inheritance, redundant program codes can be eliminated
and the use of previously defned classes may be continued.
The technology of data hiding facilitates the programmer to
design and develop safe programs that do not disturb code in
other parts of the program.
Data hiding helps programmers with data security.
The encapsulation feature provided by OOP languages allows
programmer to defne the class with many functions and
characteristics and only few functions are exposed to the user.
All object-oriented programming languages can create extended
and reusable parts of programs.
Object-oriented programming enhances the thought process of a
programmer leading to rapid development of new software in
short span of time.
The standard Template Library (STL) contains standard functions
for linked lists, queues, stacks etc. making programming really
easy. It also shortens the programs and reduces compilation
errors.
CHARACTERISTICS OF OOP
l
Objects with which you are working are analyzed—both the
attributes of those objects and the tasks that need to be
performed with and on those objects.
Emphasis is laid on data.
Programs are divided into objects.
Objects contain data and the functions that operate on the
data.
Data is hidden and cannot be accessed by outside functions.
Objects are allowed to communicate with each other through
functions. Messages are passed to objects, requesting the
objects to take action.
The same message works diferently (and appropriately) when
applied to the various objects.
A method can work appropriately with diferent types of data
it receives, without the need for separate method names.
Objects can assume or inherit properties of previously created
objects, thereby reducing the time it takes to create new
objects.
Bottom-up approach is used in program design.
Information hiding is more complete than in procedural
Diferences Between C And C++
Characteristics C C++
Application development Good for embedded devices, system-level coding Good for networking, server-side applications,
etc. gaming, etc.
File Extension .c .cpp
Compatibility with each other Not Compatible with C++. Compatible with C as C++ is a subset of C.
Ease of coding Allows us to code everything. Comes with highly advanced Object-Oriented
concepts.
Data Security Negligible High
Program division Program divided into functions. Program divided into classes and objects.
Focus/emphasis Emphasizes on functions and/or processes. Emphasizes on data rather than functions.
The main() function Can call main through other functions. Not possible to call main from any point.
Variables To be declared at the beginning of the function. Can be declared anywhere in the program.
Global variables Multiple declarations No multiple declarations.
Structures Cannot have functions as structure members. Can have functions as structure members.
Data Types Only built-in and primitive data types are supported. Boolean and string types supported in addition
No Boolean and string types. to built-in data types.
Functions Does not support functions with default Supports functions with default arrangements.
arrangements.
Namespace Not supported Supported
Mapping Cannot easily map data and functions. Data and functions can be easily mapped.
Memory management Malloc(), calloc(), free() functions. New() and delete() operators.