You are on page 1of 12

Unit I – Introduction to C++

Key Concepts of Object – Oriented Programming

Prepared By
R.Saravanakumar
Asst. Professor
Department of Connerce (IT)
Hindusthan College of Arts and Science
Prepared By : R.Saravanakumar
Introduction to c++
Object Oriented programming is a programming
style that is associated with the concept of Class,
Objects and various other concepts revolving around
these two, like Inheritance, Polymorphism,
Abstraction, Encapsulation etc.

Prepared By : R.Saravanakumar
Key Concepts of OOP
Now, let us discuss some of the main features of
Object Oriented Programming which you will be using
in C++(technically).
1. Objects
2. Classes
3. Abstraction
4. Encapsulation
5. Inheritance
6. Overloading
7. Exception Handling

Prepared By : R.Saravanakumar
Objects

Objects are the basic unit of OOP. They are instances


of class, which have data members and uses various
member functions to perform tasks.
Class

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. So, 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
Prepared By : R.Saravanakumar
object.
Abstraction
Abstraction refers to showing only the essential
features of the application and hiding the details. In C++,
classes can provide methods to the outside world to access
& use the data variables, keeping the variables hidden
from direct access, or classes can even declare everything
accessible to everyone, or maybe just to the classes
inheriting it. This can be done using access specifiers.
Encapsulation
It can also be said data binding. Encapsulation is all
about binding the data variables and functions together in
class.

Prepared By : R.Saravanakumar
Advantages of Object Oriented
Languages
1. C++ is a highly portable language and is often the language of
selection for multi-device, multi-platform app development.
2. C++ is an object-oriented programming language and includes
concepts like classes, inheritance, polymorphism, data
abstraction, and encapsulation which allow code reusability and
makes programs very maintainable.
3. C++ use multi-paradigm programming. The Paradigm means
the style of programming .paradigm concerned about logics,
structure, and procedure of the program. C++ is multi-
paradigm means it follows three paradigm Generic, Imperative,
Object Oriented.
4. It is useful for the low-level programming language and very
efficient for general purpose.
Prepared By : R.Saravanakumar
5. C++ gives the user complete control over memory
management. This can be seen both as an advantage and a
disadvantage as this increases the responsibility of the user to
manage memory rather than it being managed by the Garbage
collector.
6. The wide range of applications: From GUI applications to 3D
graphics for games to real-time mathematical simulations, C++
is everywhere.
7. C++ has a huge community around it. Community size is
important, because the larger a programming language
community is, the more support you would be likely to get.
 C++ is the 6th most used and followed tag on StackOverflow
and GitHub.
8. C++ has a very big job market as it is used in various industries
like finance, app development, game development, Virtual
reality, etc.
Prepared By : R.Saravanakumar
9. C++'s greatest strength is how scalable it could be, so
apps that are very resource intensive are usually built with
it. As a statically written language, C++ is usually more
performant than the dynamically written languages
because the code is type-checked before it is executed.
10. Compatibility with C: C++ is compatible with C and
virtually every valid C program is a valid C++ program.

Prepared By : R.Saravanakumar
C++ Declaration:
A declaration introduces one or more names into a program.
Declarations can occur more than once in a program. Therefore,
classes, structures, enumerated types, and other user-defined types
can be declared for each compilation unit. The constraint on this
multiple declaration is that all declarations must be identical.
Declarations also serve as definitions, except when the declaration:
1. Is a function prototype (a function declaration with no
function body).
2. Contains the extern specifier but no initializer (objects and
variables) or function body (functions). This signifies that the
definition is not necessarily in the current translation unit and
gives the name external linkage.

Prepared By : R.Saravanakumar
3. Is of a static data member inside a class
declaration.Because static class data members are discrete
variables shared by all objects of the class, they must be
defined and initialized outside the class declaration. (For
more information about classes and class members, see 
Classes.)
4. Is a class name declaration with no following definition,
such as class T;.
5. Is a typedef statement.

Prepared By : R.Saravanakumar
Examples of declarations that are also definitions are:
 
// Declare and define int variables i and j.
int i;
int j = 10;
 
// Declare enumeration suits.
enum suits { Spades = 1, Clubs, Hearts, Diamonds };
 
// Declare class CheckBox.
class CheckBox : public Control
{
public:
Boolean IsChecked();
virtual int ChangeState() = 0;
}; Prepared By : R.Saravanakumar
A name is considered to be declared immediately after its
declarator but before its (optional) initializer. For more
information, see Point of Declaration.
Declarations occur in a scope. The scope controls the
visibility of the name declared and the duration of the
object defined, if any. For more information about how
scope rules interact with declarations, see Scope.
An object declaration is also a definition unless it contains
the extern storage-class specifier described in 
Storage classes. A function declaration is also a definition
unless it is a prototype. A prototype is a function header
without a defining function body. The definition of an
object causes allocation of storage and appropriate
initializations for that object.
Prepared By : R.Saravanakumar

You might also like