Introduction To C++ - Chap1
Introduction To C++ - Chap1
Chapter 1.
Introduction to C++
• C++ is an object-oriented programming (OOP)
language, developed by Bjarne Stroustrup in 1983 at
AT&T Bell Labs.
• C++ is an extension of C programming (with class
construct feature) and the programs written in C
language can run in C++ compilers.
• C++ is considered as a superset of C language.
• You can create applications that will run on a wide
variety of hardware platforms such as personal
computers running Windows, Linux, UNIX, and Mac
OS .
• C++ is not purely object-oriented language because
object-oriented means to work with object and
classes, but in C++ you can write code without
creating a class.
Uses of C++
• It is used to create :
1. General systems software.
2. Drivers for various computer devices (as the C
part of C++ can handle machine level details).
3. Software for servers.
4. Software for specific systems :
applications that depend on direct hardware
manipulation under real time constraints
(Embedded Systems).
5. Also widely used in the creation of video games.
Benefits of C++ over C Language
1. There is Stronger Type Checking in C++.
2. All the OOPS features in C++ like Abstraction, Encapsulation,
Inheritance etc. makes it more useful for programmers.
3. Inline Functions in C++ instead of Macros in C language.
Inline functions make complete function body act like
Macro, safely.
4. Variables can be declared anywhere in the program in C++,
but must be declared before they are used.
5. C++ supports and allows user defined operators (i.e
Operator Overloading) and function overloading is also
supported in it.
6. C++ supports Exception Handling.
7. Supports concepts of Virtual functions, Constructors and
Destructors.
Main Features Of OO Programming
• The main focus remains on data rather than procedures.
• Object oriented programs are segmented into parts called
objects.
• Data member and functions are tied together as a data
structure (Class).
• Data can be hidden and cannot be accessed by external
functions.
• Objects can communicate among themselves using functions.
• New data and functions can be easily added anywhere within a
program whenever required.
• In an object-oriented programming language, it follows bottom
up approach, i.e. the execution of code starts from the main
which resides at the lower section and then based on the
member function call the working is done from the classes.
Structure Of C++ Program
OOPs Concepts
• Object :
– Objects are the basic unit of OOP.
– They are instances of class, which have
data members and uses various member
functions to perform tasks.
Objects
Mercedes
BMW
Maruti
OOPs Concepts
• Class :
– A class represents a template (specification) for several
objects and describes how these objects are structured
internally.
– Class is basically a blueprint for object.
– It declare & defines what data variables the object will
have and what operations can be performed on the
class's object.
– It is similar to structures in C language.
– Class can also be defined as user defined data type but
it also contains functions in it.
• Eg.
class car {
company_name,
model , weight,
Cars color , speed ….
}
OOPS Concepts
• Abstraction : showing only the required things to
the outside world while hiding the details.