SlideShare a Scribd company logo
1 of 53
Download to read offline
OOP/AKN/Part_I/1
Object Oriented Programming
using C++
Module I
Ajit K Nayak, Ph.D.
SOA University, Odisha, India
OOP/AKN/Part_I/2
Contents
1. Fundamentals
2. Simple Program
3. Operators
4. Datatypes
5. Namespace
6. Function Prototypes
7. References
8. Passing Default Arguments
9. Function Overloading
10. Inline Functions
1. Named constants
2. Dynamic memory allocations
OOP/AKN/Part_I/3
Motivation
 OOD is the current technology for software
design and development.
 C++ is a tool to develop programs/codes for
OOP.
 Therefore, this subject is the bread and
butter for all those are interested in Software
Industry.
OOP/AKN/Part_I/4
About the Course
Two Goals for this course(OO-P)
Understand OO
 Thinking in Objects
Familiar with P
 Programming in C++
OOP/AKN/Part_I/5
Course Description
In this course:
C++ is used for illustrating and
implementing Object Oriented concepts.
OOP/AKN/Part_I/6
A Sample Program
/*Author : Ajit K Nayak
Reg #:
Date:
Source file: helo.cpp
Desc: A Simple Hello, World Program
*/
#include <iostream>
using namespace std;
main() {
/* the output statement */
cout << “Hello, World!”<<endl;
}
OOP/AKN/Part_I/7
How to Write and Execute in Linux
Open a file in vi / gedit with extension as
.cpp or .cxx or .C
Write the source code
Save and exit
Compile with c++ <filename> (or g++)
Check for errors
Execute with ./a.out
Guideline:- Do write the source code in well
indented format
OOP/AKN/Part_I/8
History of C and C++
C (K & R-70s) was evolved from BCPL(M.
Richards-67) and B(K. Thompson-70).
C++ is developed by Bjarne Stroustrup in
1980
C++ is an extension to C
latest standard C++11 ISO/IEC 14882:2011
Along with C-style programming it provides
capabilities for OOP
OOP/AKN/Part_I/9
The Creator
http://www.research.att.com/~bs/homepage.html
Bjarne
Stroustrup
OOP/AKN/Part_I/10
Guidelines
…B.Stroustrup
 Knowing C is not a prerequisite to learn C++
 The better one Knows C, the harder it seems to be to
avoid writing C++ in C-style.
Suggestions for C Programmers
 Macros are almost never necessary
 Don't Declare a variable before you need it
 Don‟t use malloc(), use new operator
 Try to avoid Void*, pointer arithmetic, unions and casts
 Try thinking a program as a set of interacting agents
represented as classes and objects
 …
OOP/AKN/Part_I/11
Prerequisite
It is expected that you know:
 branching: if – else, switch-case.
 Loop: for, while, do- while.
 Array, pointer, structure, function
etc.
 Not confident!!! Rush, pickup a C book
learn and write programs on above
topics.
OOP/AKN/Part_I/12
A Sample Program
/*Author : Ajit K Nayak
Reg #:
Date:
Source file: helo.cpp
Desc: A Simple Hello, World Program
*/
#include <iostream>
using namespace std;
main() {
//the output statement
cout << “Hello, World!”<<endl;
}
OOP/AKN/Part_I/13
Basic Operators- I
 Arithmetic operators ( +, -, *, /, % )
 x = 5 % 2.5
 Increment and decrement (++, --)
 x = 3++;
 Relational and comparison operators ( ==, !=, >, <, >=, <= ) x
= 5 > 3;
 Logical operators ( !, &&, || )
 Bitwise operators ( &, |, ^, ~, <<, >> )
 x = 5 & 3
 Compound assignment (+=, -=, *=, /=, %=, >>=, <<=, &=, ^=,
|=)
 x = 3 * = 2
OOP/AKN/Part_I/14
Basic Operators- II
 Conditional ternary operator ( :? )
 x = 7== 5 ? 4 : 3 ;
 Comma operator ( , )
 a = (b=3, b+2);
 Explicit type casting operator
 int i; float f = 3.14; i = (int) f;
 Sizeof()
 x = sizeof (char);
 Precedence of Operators
 x = 5 + 7 % 2;
OOP/AKN/Part_I/15
Operators specific to C++
Stream insertion (<<)
Stream extraction (>>)
Dynamic memory allocation: new, new[ ]
Memory de-allocation: delete, delete[ ]
Scope resolution (::)
OOP/AKN/Part_I/16
Datatypes …A review
C++ has a set of fundamental types
 Boolean type (bool)
 Character type (char)
 Integer type (int)
 Floating point type (float)
 Double precision type (double)
In addition a user can define
 Enumeration type (enum)
to represent specific set of values
OOP/AKN/Part_I/17
Data types (contd.)
There also is
A type void used to signify the absence of data
From these above types we can construct
Pointer type (*)
Array type ([ ])
Reference type (&)
Finally the most powerful user-defined types
Data structures and classes(struct, class)
OOP/AKN/Part_I/18
A Classification
Boolean, character, and integer types are
collectively called as integral types
 Floating point types are called arithmetic
types
 Pointer, reference, and array are called
associated/derived types
 All of the above are built-in types
 Enumerations, structures, and classes are
called user defined types
OOP/AKN/Part_I/19
Boolean Type
A bool can have one of the two values;
true or false
It is used to express the results of logical
expressions
Example:
bool b1=a==b;
b1=true ->if a and b are of same value
= false -> otherwise
bool greater(int a, int b){ return a>b; }
 True has the value 1 and false has 0
OOP/AKN/Part_I/20
Boolean Type(contd)
Nonzero integers convert to true and 0 to
false
More Examples
bool b = 7; // b is true
int i = true // i=1
bool x = a+b // true if ….
bool y = a|b // true if a or b is true
if (b) // if b is true
What is the size required to store a certain type?
OOP/AKN/Part_I/21
Example program
int main(){
cout << "char: " << sizeof(char) << endl;
cout << "short: " << sizeof(short) << endl;
cout << "int: " << sizeof(int) << endl;
cout << "unsigned int: " << sizeof(unsigned int) << endl;
cout << "long int: " << sizeof(long int) << endl;
cout << "unsigned long int: " <<sizeof(unsigned long int)<< endl;
cout << "float: ” << sizeof(float)<<endl;
cout << "double: " << sizeof(double) << endl;
cout << "long double: " << sizeof(long double) << endl;
cout << "bool: " << sizeof(bool) << endl;
}
OOP/AKN/Part_I/22
Namespace
What is scope of a variable?
Outer
Block
{
int x=10;
…
{
int x=20;
…
}
…
}
Inner
Block
How to access
outer’s x and
Inner’s x?
If I can name the
blocks!
OOP/AKN/Part_I/23
Namespace contd.
 C++ namespaces can be used to group names
together. (give a name to a block)
 It provides a mechanism for expressing logical
grouping.
 If some declarations logically belong together
according to some criteria, they may be put in a
common namespace
 To use a namespace member, the member name
must be qualified with a namespace name and
the binary scope resolution operator
(namespace_name::member)
OOP/AKN/Part_I/24
Namespace contd.
namespace outer{
int x=10;
namespace inner{
int x=20;
}
}
Scope resolution Operator
If there is a global variable???
main(){
int x=0;
cout<<“self "<<x;
cout<<"Out "<<outer::x;
cout<<"In "<<outer::inner::x;
}
OOP/AKN/Part_I/25
Namespace Contd.
namespace mySpace{
int x=20;
int y=30,
int z=40;
}
To use these variables!
cout<< mySpace::x;
cout<< mySpace::y;
cout<< mySpace::z;
Another Way
using namespace mySpace;
cout<<x;
cout << y;
cout << z;
Note: cout and cin objects are
declared in predefined namespace
„std‟
Either write
using namespace std; or
std:: cout, std::cin etc.
OOP/AKN/Part_I/26
Function Prototype
main(){
int x = 5;
float y = 10.65;
doTask(x, y);
} //end of main
void doTask(int a, float b){
cout <<a+b<<„n‟ ;
}//end of function
void doTask(int a, float b);
Syntax:
• return_type
<function_name>(data type
of input parameter list
separated by comma );
• It can be called as function
declaration
• It is used at the time of
compilation to check if the
return value is handled
correctly and correct number
and type of arguments are
passed to the function
• Never use a function without a prototype
OOP/AKN/Part_I/27
Call By Value
#include <iostream>
using namespace std;
void increment(int);
main()
{
int i=2;
increment(i);
cout << “i = “ << i;
}
void increment(int x) { x++; }
OUTPUT ?
Explain!
OOP/AKN/Part_I/28
References
It is an alternative name for an object
It is used to specify arguments and return
values for functions in general and for
overloaded operators
Example
int i=1;
int& ir=i;
int x=ir;
ir=2;
//ir and i now refers to same value
// x=1
// i = 2
OOP/AKN/Part_I/29
References(contd.)
To ensure that a reference is a name for
something( bound to an object), we must
initialize the reference
Example:
int i=1;
int& r2;
Int& r1=i
//Error: initialization missing
//OK: r1 is now an alias for i
OOP/AKN/Part_I/30
Pointers and References
int ii = 0;
int& rr=ii;
rr++;
int *pp=&rr // or &ii
0
ii:
&ii
pp:
rr:
• pp is a variable which stores address of another variable
• rr is an alternative name (alias) for an existing variable
• The value of a reference cant be changed after initialization.
It always refers to the same object it was initialized. Which is
not the case in pointers
OOP/AKN/Part_I/31
Call By Reference
#include <iostream>
using namespace std;
void increment(int &);
main(){
int i=2;
increment(i);
cout << “i =“ << i;
}
void increment(int& x) {
x++;
}
OOP/AKN/Part_I/32
Example2
#include <iostream>
using namespace std;
int max(int&, int&);
main(){
int i=2,j=3;
cout<<max(i,j);
}
int max(int& x, int& y){
return x>y ? x:y;
}
Output?
OOP/AKN/Part_I/33
Example3
#include <iostream>
using namespace std;
int& max(int&, int&);
main(){
int i=2,j=3;
int &p=max(i,j);cout<<p; p=-30;
cout<<“i=“<i<„t‟<<“j=“<<j<<„t‟<<“p=“<<p
<<endl;
}
int& max(int &x, int &y){
return x>y ? x:y;
}
Output?
OOP/AKN/Part_I/34
References contd.
 Calls to functions that returns reference can be
put on the left side of the assignment operator.
main(){
int i=2,j=3;
max(i,j)= -30;
cout<<“i=“<i<„t‟<<“j=“<<j<<„t‟<<endl;
}
 The value –30 will be assigned to the larger of
i & j
OOP/AKN/Part_I/35
Use of passing by reference
To manipulate original values of variables
inside a function
To pass large objects
To return more than one value from a
function (virtually)
To use a function to the left side of =
operator
Any other, you may suggest!
OOP/AKN/Part_I/36
Default Arguments
Parameters can be assigned default values.
Parameters assume their default values
when no actual parameters are specified for
them in a function call.
 A default argument is type checked at the
time of function declaration and evaluated at
the time of call
 Default arguments may be provided for
trailing arguments only
OOP/AKN/Part_I/37
Example
// Find the sum of numbers in a range of values
// Between “lower” and “upper” using increment “inc”
int sum(int lower,int upper=100,int inc=1){
int sum=0;
for(int k=lower; k<=upper; k+= inc)
sum += k;
return sum;
}
main(){
cout<<sum(1);
cout<<sum(1, 10);
cout<<sum(1, 10, 2);
}
Design a default argument function with its prototype!
//5050
//55
//25
Write the prototype for sum!!!
OOP/AKN/Part_I/38
Function Overloading
A function is said to be overloaded when the same
function name is used for different purposes.
It allows you to use the same name for
different functions
void print(char);
void print(float);
Thus to overload a function we require to pass
different types of arguments to each function
with same name.
OOP/AKN/Part_I/39
Function Overloading(contd)
 Compiler decides the function to be invoked using a
series of criteria in order
1. Exact match i.e. vol(5); int vol(int)
2. Match using integral promotions i.e. char to int, float to
double etc.
3. Match using standard conversions i.e. int to double,
double to long double
4. Match using user-defined conversions i.e. conversion
between user-defined types
5. Match using the ellipsis (…) i.e unspecified number of
arguments
OOP/AKN/Part_I/40
Function Overloading(contd)
If more than one match is found, the call is rejected
by the compiler as ambiguous
Example
void print(int);
void print(const char*);
void print(double);
void print(long);
void print(char);
OOP/AKN/Part_I/41
Function Overloading(contd)
void h(char c, int i, short s,float
f){
print(c);
print(i);
print(s);
print(f);
print(„a‟);
print(49);
print(0);
print(“a”);
}
// Exact match: print(char)
// Exact match: print(int)
// integral promotion:print(int)
// integral :print(double)
// Exact match: print(char)
// Exact match: print(int)
// Exact match: print(int)
// Exact :print(const char*)
OOP/AKN/Part_I/42
Function Overloading(contd)
 Overloading solely on return value is not allowed in
C++
i.e. you cannot write
void f();
int f();
Task
Overload a function add( arg1, arg2) s.t. when both are
integers and doubles it produces the addition result,
when both are strings it produces another string by
concatenating both .
OOP/AKN/Part_I/43
Inline Functions
Every time a function is called, it takes a lot of
extra time due to
 Jumping to function
 Saving registers
 Returning to calling function etc.
When a function is small, it becomes an
overhead
 One solution is to use macros
#define max(a,b) ((a) > (b) ? (a):(b));
OOP/AKN/Part_I/44
Inline functions (contd.)
But macros has various disadvantages(?)
An alternative in C++ is to use inline
functions:
inline int max(int a, int b) {
return (a > b ? a : b);
}
An Inline function is a function that is
expanded in line when invoked.
The compiler inserts the equivalent function
code at the place of invocation
OOP/AKN/Part_I/45
Macro vs Inline function
#define square(x) x*x
main(){
cout<<square(3+2);
int y=3;
cout<<square(++y);
}
• Both fails, as macro is a blind replacement of
statements.
• Unlike macros, inline functions may be declared
any where in the program
OOP/AKN/Part_I/46
Named Constants
Only one method in C:
#define ArraySize 100;
//Macro constants
Another way in C++:
 const ArraySize =100;
Again in C++:
 constant can be used in local scope
 const is often used when the value cannot
be changed
OOP/AKN/Part_I/47
Examples of Using const
 const int count = 5;
 static const float average = 0.5;
 const float f; //error!, invalid!
 extern const float f; //ok, extern linkage
 const int c3=myFunc(3); //ok, don‟t know the
//value at compile time
 const int* p=&c2; //need to allocate space for c2
 void (const int* p) { //cant modify *p here }
 const int myFunc(int) // ok, but no use
OOP/AKN/Part_I/48
Dynamic Memory Allocation
In C we write (for a single value)
int* ip;
ip = (int*)malloc(sizeof(int) );
…
free (ip);
In C++ we will write
int* ip;
ip = new int;
...
delete ip;
OOP/AKN/Part_I/49
Dynamic Memory Allocation
In C we write (for multiple values)
int* ip;
ip = (int*)malloc(sizeof(int) * 100);
…
free ip;
In C++ we will write
int* ip;
ip = new int[100];
...
delete [ ] ip;
OOP/AKN/Part_I/50
New/Delete opearators
int* p=new int; delete p;
int* p=new int(25);delete p;
int* p=new int[25];delete []p;
Task
Find a method to declare a multi-dimensional
array using new operator
OOP/AKN/Part_I/51
Memory Leak
 Memory leak:
 when you do not free a block of memory allocated with
the new operator
 or when you make it impossible to do so.
 As a consequence your application may
eventually run out of memory and may even
cause the system to crash.
void func(){
char *ch;
ch = new char[100];
}
OOP/AKN/Part_I/52
Dangling Pointer
 Dangling pointer points to memory that has
already been freed. The storage is no longer
allocated. Trying to access it might cause a
Segmentation fault.
1. char* func() {
char str[10];
strcpy(str,"Hello!");
return(str);
}
2. int *c = new int; delete c;
*c = 3;
OOP/AKN/Part_I/53
Readings
Programming
 Bjarne Stroustrup, The C++ Programming Language, PE
 Lippman, Lajoie, C++ Primer, Addison-Wesley
 B. Eckel, Thinking in C++, Vol I and Vol II
 Deitel & Deitel, C++ How to program
 Schildt, C++ The complete reference
 S. Sahay, OOP with C++
 E. Balagurusami, Object oriented programming with C++
Concepts
 G.Booch, Object Oriented Analysis & Design
 Bertand Meyer, Object Oriented Software Construction

More Related Content

What's hot

Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesTushar B Kute
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]Rome468
 
Oop in c++ lecture 1
Oop in c++  lecture 1Oop in c++  lecture 1
Oop in c++ lecture 1zk75977
 
C# Summer course - Lecture 2
C# Summer course - Lecture 2C# Summer course - Lecture 2
C# Summer course - Lecture 2mohamedsamyali
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesUmesh Nikam
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending ClassesNilesh Dalvi
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentEduardo Bergavera
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++jehan1987
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languagesppd1961
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)indiangarg
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming ConceptsBhushan Nagaraj
 

What's hot (17)

Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
Oop in c++ lecture 1
Oop in c++  lecture 1Oop in c++  lecture 1
Oop in c++ lecture 1
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
C# Summer course - Lecture 2
C# Summer course - Lecture 2C# Summer course - Lecture 2
C# Summer course - Lecture 2
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
C++ classes
C++ classesC++ classes
C++ classes
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software Development
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)
 
Inheritance
InheritanceInheritance
Inheritance
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 

Viewers also liked

Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Ricardo Quintero
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIAjit Nayak
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlSebastien Juras
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitosRicardo Quintero
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an IntroductionAjit Nayak
 
Innovation is almost impossible for older companies
Innovation is almost impossible for older companiesInnovation is almost impossible for older companies
Innovation is almost impossible for older companiesSebastien Juras
 
Psychology explains the power of Storytelling
Psychology explains the power of StorytellingPsychology explains the power of Storytelling
Psychology explains the power of StorytellingSebastien Juras
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Ajit Nayak
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Ricardo Quintero
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expertSebastien Juras
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementAjit Nayak
 
One thing you can do to increase your charisma
One thing you can do to increase your charismaOne thing you can do to increase your charisma
One thing you can do to increase your charismaSebastien Juras
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpowerSebastien Juras
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLAjit Nayak
 
The Humming-bird’s share
The Humming-bird’s shareThe Humming-bird’s share
The Humming-bird’s shareSebastien Juras
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module IAjit Nayak
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt IIAjit Nayak
 

Viewers also liked (20)

Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part III
 
The Ultimate gift
The Ultimate giftThe Ultimate gift
The Ultimate gift
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under control
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitos
 
The badguy summary
The badguy   summaryThe badguy   summary
The badguy summary
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an Introduction
 
Innovation is almost impossible for older companies
Innovation is almost impossible for older companiesInnovation is almost impossible for older companies
Innovation is almost impossible for older companies
 
Psychology explains the power of Storytelling
Psychology explains the power of StorytellingPsychology explains the power of Storytelling
Psychology explains the power of Storytelling
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
 
Manual 02
Manual 02Manual 02
Manual 02
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expert
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
 
One thing you can do to increase your charisma
One thing you can do to increase your charismaOne thing you can do to increase your charisma
One thing you can do to increase your charisma
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpower
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
 
The Humming-bird’s share
The Humming-bird’s shareThe Humming-bird’s share
The Humming-bird’s share
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module I
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 

Similar to OOP C++ Course Introduction

Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
C++ Class & object pointer in c++ programming language
C++ Class & object pointer in c++ programming languageC++ Class & object pointer in c++ programming language
C++ Class & object pointer in c++ programming languageHariTharshiniBscIT1
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5thConnex
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxSajalKesharwani2
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Getachew Ganfur
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming CourseDennis Chang
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And AnswerJagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1stConnex
 
Object Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsObject Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsMuhammadTalha436
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiOop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiMuhammed Thanveer M
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupSyedHaroonShah4
 

Similar to OOP C++ Course Introduction (20)

OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
C++ Class & object pointer in c++ programming language
C++ Class & object pointer in c++ programming languageC++ Class & object pointer in c++ programming language
C++ Class & object pointer in c++ programming language
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Object Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsObject Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of Exams
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiOop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
 
Smart pointers
Smart pointersSmart pointers
Smart pointers
 
Introduction to programming languages part 2
Introduction to programming languages   part 2Introduction to programming languages   part 2
Introduction to programming languages part 2
 
Functions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrupFunctions And Header Files In C++ | Bjarne stroustrup
Functions And Header Files In C++ | Bjarne stroustrup
 

More from Ajit Nayak

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testingAjit Nayak
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramAjit Nayak
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagramsAjit Nayak
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UMLAjit Nayak
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationAjit Nayak
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process ModelsAjit Nayak
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQLAjit Nayak
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part IAjit Nayak
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIIAjit Nayak
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIAjit Nayak
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-BasicsAjit Nayak
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockAjit Nayak
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryAjit Nayak
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusAjit Nayak
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-NormalisationAjit Nayak
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER ModelAjit Nayak
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module IIIAjit Nayak
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module IIAjit Nayak
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIAjit Nayak
 

More from Ajit Nayak (20)

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagram
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UML
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process Models
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQL
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
NS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt IIINS2: AWK and GNUplot - PArt III
NS2: AWK and GNUplot - PArt III
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and Recovery
 
Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculus
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-Normalisation
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER Model
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module III
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module II
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part II
 

Recently uploaded

Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 

OOP C++ Course Introduction

  • 1. OOP/AKN/Part_I/1 Object Oriented Programming using C++ Module I Ajit K Nayak, Ph.D. SOA University, Odisha, India
  • 2. OOP/AKN/Part_I/2 Contents 1. Fundamentals 2. Simple Program 3. Operators 4. Datatypes 5. Namespace 6. Function Prototypes 7. References 8. Passing Default Arguments 9. Function Overloading 10. Inline Functions 1. Named constants 2. Dynamic memory allocations
  • 3. OOP/AKN/Part_I/3 Motivation  OOD is the current technology for software design and development.  C++ is a tool to develop programs/codes for OOP.  Therefore, this subject is the bread and butter for all those are interested in Software Industry.
  • 4. OOP/AKN/Part_I/4 About the Course Two Goals for this course(OO-P) Understand OO  Thinking in Objects Familiar with P  Programming in C++
  • 5. OOP/AKN/Part_I/5 Course Description In this course: C++ is used for illustrating and implementing Object Oriented concepts.
  • 6. OOP/AKN/Part_I/6 A Sample Program /*Author : Ajit K Nayak Reg #: Date: Source file: helo.cpp Desc: A Simple Hello, World Program */ #include <iostream> using namespace std; main() { /* the output statement */ cout << “Hello, World!”<<endl; }
  • 7. OOP/AKN/Part_I/7 How to Write and Execute in Linux Open a file in vi / gedit with extension as .cpp or .cxx or .C Write the source code Save and exit Compile with c++ <filename> (or g++) Check for errors Execute with ./a.out Guideline:- Do write the source code in well indented format
  • 8. OOP/AKN/Part_I/8 History of C and C++ C (K & R-70s) was evolved from BCPL(M. Richards-67) and B(K. Thompson-70). C++ is developed by Bjarne Stroustrup in 1980 C++ is an extension to C latest standard C++11 ISO/IEC 14882:2011 Along with C-style programming it provides capabilities for OOP
  • 10. OOP/AKN/Part_I/10 Guidelines …B.Stroustrup  Knowing C is not a prerequisite to learn C++  The better one Knows C, the harder it seems to be to avoid writing C++ in C-style. Suggestions for C Programmers  Macros are almost never necessary  Don't Declare a variable before you need it  Don‟t use malloc(), use new operator  Try to avoid Void*, pointer arithmetic, unions and casts  Try thinking a program as a set of interacting agents represented as classes and objects  …
  • 11. OOP/AKN/Part_I/11 Prerequisite It is expected that you know:  branching: if – else, switch-case.  Loop: for, while, do- while.  Array, pointer, structure, function etc.  Not confident!!! Rush, pickup a C book learn and write programs on above topics.
  • 12. OOP/AKN/Part_I/12 A Sample Program /*Author : Ajit K Nayak Reg #: Date: Source file: helo.cpp Desc: A Simple Hello, World Program */ #include <iostream> using namespace std; main() { //the output statement cout << “Hello, World!”<<endl; }
  • 13. OOP/AKN/Part_I/13 Basic Operators- I  Arithmetic operators ( +, -, *, /, % )  x = 5 % 2.5  Increment and decrement (++, --)  x = 3++;  Relational and comparison operators ( ==, !=, >, <, >=, <= ) x = 5 > 3;  Logical operators ( !, &&, || )  Bitwise operators ( &, |, ^, ~, <<, >> )  x = 5 & 3  Compound assignment (+=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=)  x = 3 * = 2
  • 14. OOP/AKN/Part_I/14 Basic Operators- II  Conditional ternary operator ( :? )  x = 7== 5 ? 4 : 3 ;  Comma operator ( , )  a = (b=3, b+2);  Explicit type casting operator  int i; float f = 3.14; i = (int) f;  Sizeof()  x = sizeof (char);  Precedence of Operators  x = 5 + 7 % 2;
  • 15. OOP/AKN/Part_I/15 Operators specific to C++ Stream insertion (<<) Stream extraction (>>) Dynamic memory allocation: new, new[ ] Memory de-allocation: delete, delete[ ] Scope resolution (::)
  • 16. OOP/AKN/Part_I/16 Datatypes …A review C++ has a set of fundamental types  Boolean type (bool)  Character type (char)  Integer type (int)  Floating point type (float)  Double precision type (double) In addition a user can define  Enumeration type (enum) to represent specific set of values
  • 17. OOP/AKN/Part_I/17 Data types (contd.) There also is A type void used to signify the absence of data From these above types we can construct Pointer type (*) Array type ([ ]) Reference type (&) Finally the most powerful user-defined types Data structures and classes(struct, class)
  • 18. OOP/AKN/Part_I/18 A Classification Boolean, character, and integer types are collectively called as integral types  Floating point types are called arithmetic types  Pointer, reference, and array are called associated/derived types  All of the above are built-in types  Enumerations, structures, and classes are called user defined types
  • 19. OOP/AKN/Part_I/19 Boolean Type A bool can have one of the two values; true or false It is used to express the results of logical expressions Example: bool b1=a==b; b1=true ->if a and b are of same value = false -> otherwise bool greater(int a, int b){ return a>b; }  True has the value 1 and false has 0
  • 20. OOP/AKN/Part_I/20 Boolean Type(contd) Nonzero integers convert to true and 0 to false More Examples bool b = 7; // b is true int i = true // i=1 bool x = a+b // true if …. bool y = a|b // true if a or b is true if (b) // if b is true What is the size required to store a certain type?
  • 21. OOP/AKN/Part_I/21 Example program int main(){ cout << "char: " << sizeof(char) << endl; cout << "short: " << sizeof(short) << endl; cout << "int: " << sizeof(int) << endl; cout << "unsigned int: " << sizeof(unsigned int) << endl; cout << "long int: " << sizeof(long int) << endl; cout << "unsigned long int: " <<sizeof(unsigned long int)<< endl; cout << "float: ” << sizeof(float)<<endl; cout << "double: " << sizeof(double) << endl; cout << "long double: " << sizeof(long double) << endl; cout << "bool: " << sizeof(bool) << endl; }
  • 22. OOP/AKN/Part_I/22 Namespace What is scope of a variable? Outer Block { int x=10; … { int x=20; … } … } Inner Block How to access outer’s x and Inner’s x? If I can name the blocks!
  • 23. OOP/AKN/Part_I/23 Namespace contd.  C++ namespaces can be used to group names together. (give a name to a block)  It provides a mechanism for expressing logical grouping.  If some declarations logically belong together according to some criteria, they may be put in a common namespace  To use a namespace member, the member name must be qualified with a namespace name and the binary scope resolution operator (namespace_name::member)
  • 24. OOP/AKN/Part_I/24 Namespace contd. namespace outer{ int x=10; namespace inner{ int x=20; } } Scope resolution Operator If there is a global variable??? main(){ int x=0; cout<<“self "<<x; cout<<"Out "<<outer::x; cout<<"In "<<outer::inner::x; }
  • 25. OOP/AKN/Part_I/25 Namespace Contd. namespace mySpace{ int x=20; int y=30, int z=40; } To use these variables! cout<< mySpace::x; cout<< mySpace::y; cout<< mySpace::z; Another Way using namespace mySpace; cout<<x; cout << y; cout << z; Note: cout and cin objects are declared in predefined namespace „std‟ Either write using namespace std; or std:: cout, std::cin etc.
  • 26. OOP/AKN/Part_I/26 Function Prototype main(){ int x = 5; float y = 10.65; doTask(x, y); } //end of main void doTask(int a, float b){ cout <<a+b<<„n‟ ; }//end of function void doTask(int a, float b); Syntax: • return_type <function_name>(data type of input parameter list separated by comma ); • It can be called as function declaration • It is used at the time of compilation to check if the return value is handled correctly and correct number and type of arguments are passed to the function • Never use a function without a prototype
  • 27. OOP/AKN/Part_I/27 Call By Value #include <iostream> using namespace std; void increment(int); main() { int i=2; increment(i); cout << “i = “ << i; } void increment(int x) { x++; } OUTPUT ? Explain!
  • 28. OOP/AKN/Part_I/28 References It is an alternative name for an object It is used to specify arguments and return values for functions in general and for overloaded operators Example int i=1; int& ir=i; int x=ir; ir=2; //ir and i now refers to same value // x=1 // i = 2
  • 29. OOP/AKN/Part_I/29 References(contd.) To ensure that a reference is a name for something( bound to an object), we must initialize the reference Example: int i=1; int& r2; Int& r1=i //Error: initialization missing //OK: r1 is now an alias for i
  • 30. OOP/AKN/Part_I/30 Pointers and References int ii = 0; int& rr=ii; rr++; int *pp=&rr // or &ii 0 ii: &ii pp: rr: • pp is a variable which stores address of another variable • rr is an alternative name (alias) for an existing variable • The value of a reference cant be changed after initialization. It always refers to the same object it was initialized. Which is not the case in pointers
  • 31. OOP/AKN/Part_I/31 Call By Reference #include <iostream> using namespace std; void increment(int &); main(){ int i=2; increment(i); cout << “i =“ << i; } void increment(int& x) { x++; }
  • 32. OOP/AKN/Part_I/32 Example2 #include <iostream> using namespace std; int max(int&, int&); main(){ int i=2,j=3; cout<<max(i,j); } int max(int& x, int& y){ return x>y ? x:y; } Output?
  • 33. OOP/AKN/Part_I/33 Example3 #include <iostream> using namespace std; int& max(int&, int&); main(){ int i=2,j=3; int &p=max(i,j);cout<<p; p=-30; cout<<“i=“<i<„t‟<<“j=“<<j<<„t‟<<“p=“<<p <<endl; } int& max(int &x, int &y){ return x>y ? x:y; } Output?
  • 34. OOP/AKN/Part_I/34 References contd.  Calls to functions that returns reference can be put on the left side of the assignment operator. main(){ int i=2,j=3; max(i,j)= -30; cout<<“i=“<i<„t‟<<“j=“<<j<<„t‟<<endl; }  The value –30 will be assigned to the larger of i & j
  • 35. OOP/AKN/Part_I/35 Use of passing by reference To manipulate original values of variables inside a function To pass large objects To return more than one value from a function (virtually) To use a function to the left side of = operator Any other, you may suggest!
  • 36. OOP/AKN/Part_I/36 Default Arguments Parameters can be assigned default values. Parameters assume their default values when no actual parameters are specified for them in a function call.  A default argument is type checked at the time of function declaration and evaluated at the time of call  Default arguments may be provided for trailing arguments only
  • 37. OOP/AKN/Part_I/37 Example // Find the sum of numbers in a range of values // Between “lower” and “upper” using increment “inc” int sum(int lower,int upper=100,int inc=1){ int sum=0; for(int k=lower; k<=upper; k+= inc) sum += k; return sum; } main(){ cout<<sum(1); cout<<sum(1, 10); cout<<sum(1, 10, 2); } Design a default argument function with its prototype! //5050 //55 //25 Write the prototype for sum!!!
  • 38. OOP/AKN/Part_I/38 Function Overloading A function is said to be overloaded when the same function name is used for different purposes. It allows you to use the same name for different functions void print(char); void print(float); Thus to overload a function we require to pass different types of arguments to each function with same name.
  • 39. OOP/AKN/Part_I/39 Function Overloading(contd)  Compiler decides the function to be invoked using a series of criteria in order 1. Exact match i.e. vol(5); int vol(int) 2. Match using integral promotions i.e. char to int, float to double etc. 3. Match using standard conversions i.e. int to double, double to long double 4. Match using user-defined conversions i.e. conversion between user-defined types 5. Match using the ellipsis (…) i.e unspecified number of arguments
  • 40. OOP/AKN/Part_I/40 Function Overloading(contd) If more than one match is found, the call is rejected by the compiler as ambiguous Example void print(int); void print(const char*); void print(double); void print(long); void print(char);
  • 41. OOP/AKN/Part_I/41 Function Overloading(contd) void h(char c, int i, short s,float f){ print(c); print(i); print(s); print(f); print(„a‟); print(49); print(0); print(“a”); } // Exact match: print(char) // Exact match: print(int) // integral promotion:print(int) // integral :print(double) // Exact match: print(char) // Exact match: print(int) // Exact match: print(int) // Exact :print(const char*)
  • 42. OOP/AKN/Part_I/42 Function Overloading(contd)  Overloading solely on return value is not allowed in C++ i.e. you cannot write void f(); int f(); Task Overload a function add( arg1, arg2) s.t. when both are integers and doubles it produces the addition result, when both are strings it produces another string by concatenating both .
  • 43. OOP/AKN/Part_I/43 Inline Functions Every time a function is called, it takes a lot of extra time due to  Jumping to function  Saving registers  Returning to calling function etc. When a function is small, it becomes an overhead  One solution is to use macros #define max(a,b) ((a) > (b) ? (a):(b));
  • 44. OOP/AKN/Part_I/44 Inline functions (contd.) But macros has various disadvantages(?) An alternative in C++ is to use inline functions: inline int max(int a, int b) { return (a > b ? a : b); } An Inline function is a function that is expanded in line when invoked. The compiler inserts the equivalent function code at the place of invocation
  • 45. OOP/AKN/Part_I/45 Macro vs Inline function #define square(x) x*x main(){ cout<<square(3+2); int y=3; cout<<square(++y); } • Both fails, as macro is a blind replacement of statements. • Unlike macros, inline functions may be declared any where in the program
  • 46. OOP/AKN/Part_I/46 Named Constants Only one method in C: #define ArraySize 100; //Macro constants Another way in C++:  const ArraySize =100; Again in C++:  constant can be used in local scope  const is often used when the value cannot be changed
  • 47. OOP/AKN/Part_I/47 Examples of Using const  const int count = 5;  static const float average = 0.5;  const float f; //error!, invalid!  extern const float f; //ok, extern linkage  const int c3=myFunc(3); //ok, don‟t know the //value at compile time  const int* p=&c2; //need to allocate space for c2  void (const int* p) { //cant modify *p here }  const int myFunc(int) // ok, but no use
  • 48. OOP/AKN/Part_I/48 Dynamic Memory Allocation In C we write (for a single value) int* ip; ip = (int*)malloc(sizeof(int) ); … free (ip); In C++ we will write int* ip; ip = new int; ... delete ip;
  • 49. OOP/AKN/Part_I/49 Dynamic Memory Allocation In C we write (for multiple values) int* ip; ip = (int*)malloc(sizeof(int) * 100); … free ip; In C++ we will write int* ip; ip = new int[100]; ... delete [ ] ip;
  • 50. OOP/AKN/Part_I/50 New/Delete opearators int* p=new int; delete p; int* p=new int(25);delete p; int* p=new int[25];delete []p; Task Find a method to declare a multi-dimensional array using new operator
  • 51. OOP/AKN/Part_I/51 Memory Leak  Memory leak:  when you do not free a block of memory allocated with the new operator  or when you make it impossible to do so.  As a consequence your application may eventually run out of memory and may even cause the system to crash. void func(){ char *ch; ch = new char[100]; }
  • 52. OOP/AKN/Part_I/52 Dangling Pointer  Dangling pointer points to memory that has already been freed. The storage is no longer allocated. Trying to access it might cause a Segmentation fault. 1. char* func() { char str[10]; strcpy(str,"Hello!"); return(str); } 2. int *c = new int; delete c; *c = 3;
  • 53. OOP/AKN/Part_I/53 Readings Programming  Bjarne Stroustrup, The C++ Programming Language, PE  Lippman, Lajoie, C++ Primer, Addison-Wesley  B. Eckel, Thinking in C++, Vol I and Vol II  Deitel & Deitel, C++ How to program  Schildt, C++ The complete reference  S. Sahay, OOP with C++  E. Balagurusami, Object oriented programming with C++ Concepts  G.Booch, Object Oriented Analysis & Design  Bertand Meyer, Object Oriented Software Construction