C++ Notes
C++ Notes
C++ today's dominant computer language because of its striking features like Data Encapsulation,
Polymorphism, Inheritance ofc, which are not covered in the procedure oriented languages such as
Pascal, C. These features have benefits like easy upgradation of programs, reusability of code, data
secunty, clear view of system and simple interface descriptions with external systems.
This chapter focuses on the importance of Object Oriented Approach over Procedurial Oriented
approach, the basic concepts related to OOP and applications of OOP
Evolution of C++
C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratories in Murray Hill, New Jersey,
USA, in the early 1980's. C++ is an extension of C with a major addition of the class construct
feature of Simula 67. Instiuly, Bjame Stroustrup called the new language "C with classes Rick
Mascitti coined the name C++ with addition of unary increment operator + representing
enhancement in C language in 1983. Thus, in 1983, the name was changed to C++
The most important elements added to C to create C++ are concerned with classes, objects and OOP
However, C++ has many other features as well, including an improved approach to 1/0 and a new
way to write comments.
Procedure-Oriented Programming
Fortran, Pascal, COBOL, C. and similar traditional programming languages are procedure oriented
languages. A program in a procedure-oriented language is a list of instructions and nach instruction
tells the computer to do something such as reading, writing and calculating
In this approach, a large program divided indu functions and each function has a cinarly defined
purpose and a clearly defined interface.
This approach is also known as structured programming approach. No matter how well the
structured programming approach is implemented, large programs become excessively complex
B. Globalisation of Data
In procedure-oriented programming, the primary focus is on functions, in the development of
functions, data is given the least importance. To make the data accessed by all the function, they are
to be placed as global as shown in fig. 13. Making data global alows any function to manipulate it
but this may result in losing any important information.
Most language like Pascal and C also support local data, which is hidden within a singe function,
Fig. 1.4 shows the relationship between local and global data
Main problem in global data is that anyone can change or destroy the global data.
In this approach, it is very difficult to create the new data types like complex numbers dala type,
dates data type, two-dimensional co-ordinates data type etc. The property to create your own data
types is known as extensibility. Therefore, procedure-oriented languages are not usually extensible.
14) Object-Oriented
In C++, object-oriented concepts like data hiding, encapsulation, and data abstraction can easily be
implemented using keyword class, private, public, and protected access specifiers. Object-oriented
makes development and maintenance easier.
Object-Oriented Programming
Object-Oriented Programming (OOP) approach binds the data and the functions the operate on that
data into a single entity. Such an entity is called an object. Functions of an object can only access its
data. You can't access the data directly. For example, you want to read a data item in an object, you
call a member function in t will mad the data item a n and retum the value to you. This secures data
from any changers from outside Thus, DOP gives more emphasis on data
A C++ program typically consists of a number of objects which communicate with eac other by
calling one anothers member functions. Calling an objects member functions also referred to as
sending a message to the object.
Objects are independent of each other. They are responsible for managing their own state and
offering services to other objects. Therefore, new objects can be easily added whenever necessary.