KEMBAR78
OOPS Advanced | PDF
   
OOPs – Advanced
   
OOPs – Const Dest
●
Constructor : Things to do when a new 
object is created
●
Destructor : Things to do when object's life 
ends. 
   
OOPs – Const Dest
   
OOPs – More Constructors
   
OOPs – More Constructors : 
ERRATA
   
Lets answer the TRICK Question
   
Lets do the TRICK Question
15 years back, before C++ came in,
Address(cool) = Address(coolness)
COMPILER OPTIMIZATION!
   
Lets answer the TRICK Question
●
While making a COPY of the parameter, the 
Copy­constructor of the parameter should 
be called!
●
Thus the compiler optimization was invalid.
   
OOPs – Interfaces
●
Class definition, no logic
●
Defines what functions and data (vars) 
should be present in the Class that 
IMPLEMENTS an interface.
●
   
OOPs – Interfaces
   
OOPs – Interfaces
   
OOPs – Abstract Class
●
Small extension of Interfaces
●
Instead of requiring subclass to implement 
ALL virtual functions, it also defines some 
function's body.
   
OOPs – Abstract Class
   
OOPs – Virtual keyword
OUTPUT for each?
   
OOPs – Virtual keyword
   
OOPs – Static Variables
   
OOPs – Static Variables
   
OOPs – Inline functions
   
OOPs – Friend Function
PS: Never encountered a good use for a friend function  :­/
   
OOPs – Static Var and Function
Output?
   
OOPs – Static Var and Function
   
OOPs – Namespace
   
OOPs – Namespace
   
OOPs – Namespace
   
OOPs – Namespace
   
OOPs – Shallow Copy
Output?
   
OOPs – Shallow Copy
   
OOPs – Deep Copy
Output?
   
OOPs – Deep Copy
   
Inheritance ­ advanced
●
Types of inheritance :
●
Public 
●
Private 
●
Protected
   
Inheritance ­ advanced
●
Types of inheritance :
●
Public 
●
Private 
●
Protected
   
Inheritance ­ advanced
●
Types of inheritance :
●
Public 
●
Private 
●
Protected
   
CLASS DIAGRAM
READUP : UML Elements
   
QUESTIONS
   
Q) Variables
●
What is the size of a NULL value in C++?
   
Q) Variables
●
What is the size of a NULL value in C++?
●
1 Byte
   
Q) Functions
●
Python uses which of the following?
●
Call by value
●
Call by reference
●
Both, interchangeably
●
None of the above
   
Q) Functions
●
Python uses which of the following?
●
Call by value
●
Call by reference
●
Both, interchangeably
●
None of the above : It uses Call­by­object
   
Q) C'tors and d'tors
OUTPUT?
   
Q) C'tors and d'tors
   
Q) This pointer
What is the error here?
   
Q) What are the OOPs conepts 
used here?
   
Q) Inheritance
WHAT VARIABLES ARE ACCESSIBLE
TO
Function foo() ?
   
Q) Inheritance
WHAT VARIABLES ARE ACCESSIBLE
TO
Function foo() ?
a_v1, a_v2, b_v2, b_v3, c_v2, c_v3
WHAT VARIABLES ARE ACCESSIBLE
TO
Object d?
   
Q) Inheritance
WHAT VARIABLES ARE ACCESSIBLE
TO
Function foo() ?
a_v1, a_v2, b_v2, b_v3, c_v2, c_v3
WHAT VARIABLES ARE ACCESSIBLE
TO
Object d?
a_v2, c_v3
   
Q) This pointer
What is the error here?
   
Q) Interfaces and Abs Class
●
Can you instanciate an object of an Abstract 
class?
   
Q) Interfaces and Abs Class
●
Can you instanciate an object of an Abstract 
class?
●
NO
   
Q) Interfaces and Abs Class
●
Can a function be final and virtual at the 
same time?
   
Q) Interfaces and Abs Class
●
Can you instanciate an object of an Abstract 
class?
●
NO
– Virtual functions HAVE to be over­ridden
– Final functions CANNOT be over­ridden

OOPS Advanced