 What is “C++” ?
 Benefits of C++ over C language
 Object Oriented Programming in C++
 Datatypes in C++
 Operators in C++
 Variables in C++
 Syntax & Structure of C++ Programme
 Basic example of C++
 Creating Classes in C++
 Controlling structures in C++
 Example of C++
 References
 C++ is an extension of C programming and was
developed by Bjarne Stroustup at AT & T’s Bell
Laboratory in USA in 1980s.
 C++ is an intermediate level language, as it
comprises both high level and low level language
features.
 C++ is a free form, general-purpose language.
 C++ is an Object Oriented Programming
language but is not purely Object Oriented
because of its features like Friend and Virtual
 All the OOP’s features in C++ like Abstraction,
Encapsulation, Inheritance etc makes it more
worthy and useful for programmers.
 C++ supports and allows user defined operators (i.e
Operator Overloading) and function overloading is
also supported in it.
 Inline Functions in C++ instead of Macros in C
language. Inline functions make complete function
body act like Macro, safely.
 Variables can be declared anywhere in the program
in C++, but must be declared before they are used.
 Object-oriented means a
term which is interpreted
differently by different
people.
 Programs are divided into
Objects.
 Data is hidden & not
accessible by external
functions.
 New data & functions can
be added whenever
necessary.
Object
Class
Data Encapsulation
Data Abstraction
Inheritance
Polymorphism
Dynamic Binding
Message Passing
Concepts
1. Object: They are the basic run-time entities, they represent a
user-defined data.
2. Class: It is a collection of objects of similar type, they’re user
defined data types.
3. Data Encapsulation: Wrapping up of data & function into a
single unit called Class.
4. Data Abstraction: It is the act of representing essential features
without including the background details.
5. Inheritance: The mechanism of deriving a new class from an old
one i.e. objects of one class acquire the properties of objects of
another class (reusability of code).
6. Polymorphism: It is the ability to take more than one form.
7. Dynamic Binding: It refers to any code that is called is not
known until runtime.
8. Message passing: A set of objects that communicate with each
other.
User-Defined type Built-in type Derived type
Structure
Union
Class
Enumeration
Array
Function
Pointer
Reference
Void
Integral
type
Floating
type
Char(1)
Int(2) & long int(4)
Double(8)
Float(4)
 Assignment(=): Assign the values.
 Mathematical(+,-,*,/,%): Mathematical operations.
 Relational(< >,<=,>=,++,!=): Comparison.
 Logical(&&,||): Combine 2 different expression.
 Bitwise(&,|,^,~): Change individual bits into number.
 Shift(<<,>>,>>>): Shift bits of any variable.
 Unary(++,--): Used with one operand only.
 Ternary(?:): Used with 3 operands.
 Comma(,): Separation of variables and expressions.
 In C++, the declaration of variable is allowed
anywhere in the scope i.e. Variables can be
declared right at the place of its use.
 There are total 64 keywords in C++ given by ANSI.
Scope of Variables
All the variables have their area of functioning, and
out of that boundary they don't hold their value, this
boundary is called scope of the variable.
 Global Variables
 Local variables
 Those variables which are
once declared and can be
used throughout the lifetime
of the program by any class
or any function.
 They must be declared
outside the main() function.
 Those variables which exist
only between the curly
braces, in which its declared.
 Outside that they are
unavailable and leads to
compile time error.
Cout<<: Output operator
Cin>>:Intput operator
OUTPUT
 Class is a collection of objects of similar type.
 Classes are user defined datatypes.
 Once class is defined, then object is created & member fucntions are used.
Sequence Selection Loop
Action 1
Action 2
Action 3
Entry
Exit
Straight line
Switch
If--else
While
Do while
For
Condition
Is
Tested
(True/False) Loops
runs
In
it
Action 1 Action 2
Action 3
Entry
Exit
Condition
 If-else
 Switch
True False
Action 1
Entry
Exit
Condition
 Do-while
 While
 For
True
False
Action 2
Loop
 Kanetkar, P.Y. “Let Us C++” Seventh Edition
2007, pp. 34-37, BPB Publications, New
Delhi-1.
 Balaguruswamy, E. “Object Oriented
Programming with C++” Eighth Edition 2016,
pp. 14-40, Mc Graw Hill Education (India)
Private Limited, New Delhi-110016.
Introduction to C++ Programming

Introduction to C++ Programming

  • 2.
     What is“C++” ?  Benefits of C++ over C language  Object Oriented Programming in C++  Datatypes in C++  Operators in C++  Variables in C++  Syntax & Structure of C++ Programme  Basic example of C++  Creating Classes in C++  Controlling structures in C++  Example of C++  References
  • 3.
     C++ isan extension of C programming and was developed by Bjarne Stroustup at AT & T’s Bell Laboratory in USA in 1980s.  C++ is an intermediate level language, as it comprises both high level and low level language features.  C++ is a free form, general-purpose language.  C++ is an Object Oriented Programming language but is not purely Object Oriented because of its features like Friend and Virtual
  • 4.
     All theOOP’s features in C++ like Abstraction, Encapsulation, Inheritance etc makes it more worthy and useful for programmers.  C++ supports and allows user defined operators (i.e Operator Overloading) and function overloading is also supported in it.  Inline Functions in C++ instead of Macros in C language. Inline functions make complete function body act like Macro, safely.  Variables can be declared anywhere in the program in C++, but must be declared before they are used.
  • 5.
     Object-oriented meansa term which is interpreted differently by different people.  Programs are divided into Objects.  Data is hidden & not accessible by external functions.  New data & functions can be added whenever necessary. Object Class Data Encapsulation Data Abstraction Inheritance Polymorphism Dynamic Binding Message Passing Concepts
  • 6.
    1. Object: Theyare the basic run-time entities, they represent a user-defined data. 2. Class: It is a collection of objects of similar type, they’re user defined data types. 3. Data Encapsulation: Wrapping up of data & function into a single unit called Class. 4. Data Abstraction: It is the act of representing essential features without including the background details. 5. Inheritance: The mechanism of deriving a new class from an old one i.e. objects of one class acquire the properties of objects of another class (reusability of code). 6. Polymorphism: It is the ability to take more than one form. 7. Dynamic Binding: It refers to any code that is called is not known until runtime. 8. Message passing: A set of objects that communicate with each other.
  • 7.
    User-Defined type Built-intype Derived type Structure Union Class Enumeration Array Function Pointer Reference Void Integral type Floating type Char(1) Int(2) & long int(4) Double(8) Float(4)
  • 8.
     Assignment(=): Assignthe values.  Mathematical(+,-,*,/,%): Mathematical operations.  Relational(< >,<=,>=,++,!=): Comparison.  Logical(&&,||): Combine 2 different expression.  Bitwise(&,|,^,~): Change individual bits into number.  Shift(<<,>>,>>>): Shift bits of any variable.  Unary(++,--): Used with one operand only.  Ternary(?:): Used with 3 operands.  Comma(,): Separation of variables and expressions.
  • 9.
     In C++,the declaration of variable is allowed anywhere in the scope i.e. Variables can be declared right at the place of its use.  There are total 64 keywords in C++ given by ANSI. Scope of Variables All the variables have their area of functioning, and out of that boundary they don't hold their value, this boundary is called scope of the variable.  Global Variables  Local variables
  • 10.
     Those variableswhich are once declared and can be used throughout the lifetime of the program by any class or any function.  They must be declared outside the main() function.  Those variables which exist only between the curly braces, in which its declared.  Outside that they are unavailable and leads to compile time error.
  • 11.
  • 12.
  • 13.
     Class isa collection of objects of similar type.  Classes are user defined datatypes.  Once class is defined, then object is created & member fucntions are used.
  • 14.
    Sequence Selection Loop Action1 Action 2 Action 3 Entry Exit Straight line Switch If--else While Do while For Condition Is Tested (True/False) Loops runs In it
  • 15.
    Action 1 Action2 Action 3 Entry Exit Condition  If-else  Switch True False
  • 16.
    Action 1 Entry Exit Condition  Do-while While  For True False Action 2 Loop
  • 19.
     Kanetkar, P.Y.“Let Us C++” Seventh Edition 2007, pp. 34-37, BPB Publications, New Delhi-1.  Balaguruswamy, E. “Object Oriented Programming with C++” Eighth Edition 2016, pp. 14-40, Mc Graw Hill Education (India) Private Limited, New Delhi-110016.