SlideShare a Scribd company logo
1 of 50
Structure Definitions
struct time
{
int hour;
int min;
int second;
}
Accessing members of structure
time t;
cout<<t.hour;
time * timeptr;
Using pointers
timeptr = &t;
cout<<timeptr->hour;
(*timeptr).hour;
Example
Classes and Objects
 A class can be described as a collection of data
members and member functions.
 Functions are called member functions and define a
set of operations that can be performed on the data
members of the class.
 The association of data and member functions are
called encapsulation.
Class objects
 The process of creating objects(variables) of the class
is called class instantiation. Necessary resources are
allocated only when the class is instantiated.
 The syntax is as follows:
 Class className ObjectName…..
 Ex: class student s1;
Accessing Class members
 Class members are accessed using member access
operator , dot(.)
 Syntax : ObjectName.Datamember;
 Example: Student s1;
 s1.rollno;
 s1.printdetails();
Defining member functions
 Member functions of the class can be defined in any
one of the following ways
 Inside the class specification
 Outside the class specification
Member functions outside the
class body
Example
Access specifiers
 Private: The private members of a class have strict access
control. Only the member functions of the same class can access
these members. It prevents accidental modifications of the data
members.
class person
{
private:
int age;
int getage();
};
Person p1;
p1.age = 10; // cannot access private data
p1.getage(); // cannot access private function
Public members
 The members of a class which are visible outside the class
are declared in public section.
class person
{
public:
int age;
int getage();
};
Person p1;
p1.age = 10; // can access public datat
p1.getage(); // can access public function
Protected members
 The access control of protected members is similar to
private members and has significance to inheritance.
 Empty classes;
 Class xyz{};
 Class Empty {};
Constructors and Destructors
 Constructors:
 The constructor gets called automatically for each
object that has just got created.
 It appears as member function of each class, whether
defined or not.
 It has same name as the class. It may or may not take
parameters .
 It does not return anything
 The prototype is
 Class name(parameter list);
 Example
Parameterized constructors
 Constructors with arguments are called parameterized
constructors.
Example
Dynamic memory
Operators new and new[]
The new operator offers dynamic storage allocation similar to
the standard library function malloc.
Throws an exception when memory allocation fails.
pointer = new type
pointer = new type [number_of_elements]
int * b;
b = new int [5];
Operators delete and delete[]
delete pointer;
delete [] pointer;
 Example
Destructor
 When an object is no longer needed it can be
destroyed. A class can have a member function called
destructor which is invoked when an object is
destroyed.
Example
Constructors with default
arguments.
 Constructors with dynamic operations
 Example 2
Copy constructor
 The copy constructor is a special type of parameterized
constructor.
 It copies one object to another.
 It can be called when an object is created and equated
to an existing object at the same time.
 Vector v1(5), v2(5);
 v1= v2; // operator = invoked
 vector v3 = v2; // copy constructor is invoked.
 Vector v3(v2)
 vector *ptr = new vector(v1);
Passing Objects as Arguments
 Methods
 Pass by value
 Example
 Pass and return by reference
 Example
 Array of objects
this pointer
 The this pointer points at the object with respect to which
the function was called.
 this pointer is always a constant pointer.
 The compiler converts the class into a structure with only
data members.
class dist
{ int feet,inch;
public:
int getfeet();
int getinch();
}
struct dist
{
int feet, inch;
};
int getfeet(dist * const);
int getinch(dist * const);
int dist::getfeet()
{
Return feet;
}
int getfeet(dist * const this)
{
return this->feet;
}
OPERATOR OVERLOADING
 Operator overloading feature of C++ is one of the
methods of realizing polymorphism.
 Operator overloading helps in
 Extending capability of operators to operate on user
defined data.
 Data conversion
 Operator overloading extends the semantics of an
operator without changing its syntax.
Unary operator overloading
 Example with member function
 Example with operator overloading
 Operator keyword
 The keyword operator facilitates overloading of the C++
operators.
Operator return values
 idx1 = idx2++;
 Example
 Binary Operator overloading
Arithmetic operators
 Adding two objects of a class
 Direct Addition
 Overloaded + operator
 String Example
Comparison operators
 Example
 Arithmetic assignment operators
Data conversion
 Example
Conversion between objects of
different classes.
 ClassA objecta;
 ClassB objectb;
 objecta = objectb;
 Conversion routine in the source object’s class is
implemented using an operator function
 In objecta= objectb, objectb is the source object of
classB
Conversion between objects of
different classes.
 Example
Conversion routine in destination
object: Constructor function
 Example
Overloading with friend functions
Example
Example 2
Inheritance
 Inheritance is a technique of organizing information
in a hierarchical form.
 Inheritance allows new classes to be built from older
and less specialized class.
 Classes are created by first inheriting all the variables
and behavior defined by some primitive class and then
adding specialized variables and behaviors.
 Inheritance allows code reusability.
Base class and derived class
 Example
TYPES OF INHERITANCE
Constructors
Zero argument constructor in base and derived class
Example
Parameterized constructors in base and derived classes
Example
Parameterized constructor in derived class
Example
Multilevel Inheritance
 Derivation of a class from another derived class is
called multilevel inheritance.
 Example
 Constructor Example
Multiple Inheritance
 Example
 Example
Hierarchical Inheritance
Example
Multipath Inheritance
 The form of inheritance which derives a new class by
multiple inheritance of base classes, which are derived
earlier form the same base class is known as multipath
inheritance.
 Example
 Problems with multipath inheritance:
 Ambiguity due to duplicate copies of members
inherited from the base class.
 Virtual Base class is used to solve the ambiguity issue in
multipath inheritance.
Hybrid inheritance
 Write a program to implement hybrid inheritance
shown in the diagram. Consider necessary details for
all the classes.

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...JAINAM KAPADIYA
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in javaAtul Sehdev
 
Constructor&method
Constructor&methodConstructor&method
Constructor&methodJani Harsh
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in javakamal kotecha
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects newlykado0dles
 
Oop Constructor Destructors Constructor Overloading lecture 2
Oop Constructor  Destructors Constructor Overloading lecture 2Oop Constructor  Destructors Constructor Overloading lecture 2
Oop Constructor Destructors Constructor Overloading lecture 2Abbas Ajmal
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Abu Saleh
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classesFajar Baskoro
 
Java lec class, objects and constructors
Java lec class, objects and constructorsJava lec class, objects and constructors
Java lec class, objects and constructorsJan Niño Acierto
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
Classes and objects
Classes and objectsClasses and objects
Classes and objectsNilesh Dalvi
 

What's hot (20)

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Constructor&method
Constructor&methodConstructor&method
Constructor&method
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Oop Constructor Destructors Constructor Overloading lecture 2
Oop Constructor  Destructors Constructor Overloading lecture 2Oop Constructor  Destructors Constructor Overloading lecture 2
Oop Constructor Destructors Constructor Overloading lecture 2
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
Lect 1-java object-classes
Lect 1-java object-classesLect 1-java object-classes
Lect 1-java object-classes
 
Java lec class, objects and constructors
Java lec class, objects and constructorsJava lec class, objects and constructors
Java lec class, objects and constructors
 
Inheritance
InheritanceInheritance
Inheritance
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 

Viewers also liked

Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...
Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...
Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...ATIF HUSSAIN
 
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....dr m m bagali, phd in hr
 
Technology Hill SMO PowerPoint
Technology Hill SMO PowerPointTechnology Hill SMO PowerPoint
Technology Hill SMO PowerPointTechnology Hill
 
Заявление министерства юстиции
Заявление министерства юстицииЗаявление министерства юстиции
Заявление министерства юстицииAnatol Alizar
 
Solid Waste Management presentation to KSPCB
Solid Waste Management presentation to KSPCBSolid Waste Management presentation to KSPCB
Solid Waste Management presentation to KSPCBApnaComplex
 
Dhaka South City Corporation: Structure, Finance and Personal Management
Dhaka South City Corporation: Structure, Finance and Personal ManagementDhaka South City Corporation: Structure, Finance and Personal Management
Dhaka South City Corporation: Structure, Finance and Personal ManagementAhasan Uddin Bhuiyan
 
Las condiciones-del-aprendizaje por Dennis Montufar
Las condiciones-del-aprendizaje por Dennis MontufarLas condiciones-del-aprendizaje por Dennis Montufar
Las condiciones-del-aprendizaje por Dennis MontufarDennisito1995
 
environmental control of poultry farms PLC based project presentation
environmental control of poultry farms PLC based project presentationenvironmental control of poultry farms PLC based project presentation
environmental control of poultry farms PLC based project presentationAhsan Naeem Chaudary
 
Presentation 2 student x
Presentation 2 student xPresentation 2 student x
Presentation 2 student xAsma Wasim
 
Progetto Digital Strategy Amadori
Progetto Digital Strategy AmadoriProgetto Digital Strategy Amadori
Progetto Digital Strategy AmadoriTecla
 
Web analytics: i cruscotti
Web analytics: i cruscottiWeb analytics: i cruscotti
Web analytics: i cruscottiLeonardo Bellini
 
ERTMS Presentation
ERTMS PresentationERTMS Presentation
ERTMS PresentationMartyn Tobin
 
Need and Importance of ICT Based Library Services in ODL: With Special Refere...
Need and Importance of ICT Based Library Services in ODL: With Special Refere...Need and Importance of ICT Based Library Services in ODL: With Special Refere...
Need and Importance of ICT Based Library Services in ODL: With Special Refere...Anupama Chetia
 
Raggiungere 500 collegamenti su LinkedIn
Raggiungere 500 collegamenti su LinkedInRaggiungere 500 collegamenti su LinkedIn
Raggiungere 500 collegamenti su LinkedInLeonardo Bellini
 
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안Lee Sung Hoon
 
Plan de Trabajo Min. Adolescente UPSur
Plan de Trabajo Min. Adolescente UPSurPlan de Trabajo Min. Adolescente UPSur
Plan de Trabajo Min. Adolescente UPSurAdventistas APC
 

Viewers also liked (20)

Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...
Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...
Projects Department Weekly Report - SVC AlJouf-2, Dynamic and Static Rea... d...
 
Shagree sintesi primovolotermico
Shagree sintesi primovolotermicoShagree sintesi primovolotermico
Shagree sintesi primovolotermico
 
Presentazione A@gres orientagate 2013
Presentazione A@gres  orientagate 2013Presentazione A@gres  orientagate 2013
Presentazione A@gres orientagate 2013
 
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....
MM Bagali,,,,,,,,, HR, HRM, HRD, PhD research, India.......High performance ....
 
Biz Presentation 2013
Biz Presentation 2013Biz Presentation 2013
Biz Presentation 2013
 
Technology Hill SMO PowerPoint
Technology Hill SMO PowerPointTechnology Hill SMO PowerPoint
Technology Hill SMO PowerPoint
 
Заявление министерства юстиции
Заявление министерства юстицииЗаявление министерства юстиции
Заявление министерства юстиции
 
Solid Waste Management presentation to KSPCB
Solid Waste Management presentation to KSPCBSolid Waste Management presentation to KSPCB
Solid Waste Management presentation to KSPCB
 
Dhaka South City Corporation: Structure, Finance and Personal Management
Dhaka South City Corporation: Structure, Finance and Personal ManagementDhaka South City Corporation: Structure, Finance and Personal Management
Dhaka South City Corporation: Structure, Finance and Personal Management
 
Las condiciones-del-aprendizaje por Dennis Montufar
Las condiciones-del-aprendizaje por Dennis MontufarLas condiciones-del-aprendizaje por Dennis Montufar
Las condiciones-del-aprendizaje por Dennis Montufar
 
environmental control of poultry farms PLC based project presentation
environmental control of poultry farms PLC based project presentationenvironmental control of poultry farms PLC based project presentation
environmental control of poultry farms PLC based project presentation
 
Presentation 2 student x
Presentation 2 student xPresentation 2 student x
Presentation 2 student x
 
Progetto Digital Strategy Amadori
Progetto Digital Strategy AmadoriProgetto Digital Strategy Amadori
Progetto Digital Strategy Amadori
 
EXPONENTES DEL CONDUCTISMO
EXPONENTES DEL CONDUCTISMO EXPONENTES DEL CONDUCTISMO
EXPONENTES DEL CONDUCTISMO
 
Web analytics: i cruscotti
Web analytics: i cruscottiWeb analytics: i cruscotti
Web analytics: i cruscotti
 
ERTMS Presentation
ERTMS PresentationERTMS Presentation
ERTMS Presentation
 
Need and Importance of ICT Based Library Services in ODL: With Special Refere...
Need and Importance of ICT Based Library Services in ODL: With Special Refere...Need and Importance of ICT Based Library Services in ODL: With Special Refere...
Need and Importance of ICT Based Library Services in ODL: With Special Refere...
 
Raggiungere 500 collegamenti su LinkedIn
Raggiungere 500 collegamenti su LinkedInRaggiungere 500 collegamenti su LinkedIn
Raggiungere 500 collegamenti su LinkedIn
 
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안
[마케팅전략] 2012년 게임어플리케이션 마케팅 전략 및 실행안
 
Plan de Trabajo Min. Adolescente UPSur
Plan de Trabajo Min. Adolescente UPSurPlan de Trabajo Min. Adolescente UPSur
Plan de Trabajo Min. Adolescente UPSur
 

Similar to Unit ii

C questions
C questionsC questions
C questionsparm112
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)rashmita_mishra
 
Object oriented design
Object oriented designObject oriented design
Object oriented designlykado0dles
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Getachew Ganfur
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming CourseDennis Chang
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classesrsnyder3601
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programmingnirajmandaliya
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptishan743441
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)nirajmandaliya
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaGlenn Guden
 

Similar to Unit ii (20)

C questions
C questionsC questions
C questions
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Class and object
Class and objectClass and object
Class and object
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
 
Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02Ccourse 140618093931-phpapp02
Ccourse 140618093931-phpapp02
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
OOPs & C++ UNIT 3
OOPs & C++ UNIT 3OOPs & C++ UNIT 3
OOPs & C++ UNIT 3
 
Chapter 13 introduction to classes
Chapter 13 introduction to classesChapter 13 introduction to classes
Chapter 13 introduction to classes
 
My c++
My c++My c++
My c++
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
Virtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.pptVirtual Function and Polymorphism.ppt
Virtual Function and Polymorphism.ppt
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 

More from donny101

Unit vos - File systems
Unit vos - File systemsUnit vos - File systems
Unit vos - File systemsdonny101
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systemsdonny101
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationdonny101
 
Unit iiios Storage Management
Unit iiios Storage ManagementUnit iiios Storage Management
Unit iiios Storage Managementdonny101
 
Unit 1os processes and threads
Unit 1os processes and threadsUnit 1os processes and threads
Unit 1os processes and threadsdonny101
 

More from donny101 (9)

Unit v
Unit vUnit v
Unit v
 
Unit iv
Unit ivUnit iv
Unit iv
 
Unit iii
Unit iiiUnit iii
Unit iii
 
Unit 1
Unit  1Unit  1
Unit 1
 
Unit vos - File systems
Unit vos - File systemsUnit vos - File systems
Unit vos - File systems
 
Unit ivos - file systems
Unit ivos - file systemsUnit ivos - file systems
Unit ivos - file systems
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
 
Unit iiios Storage Management
Unit iiios Storage ManagementUnit iiios Storage Management
Unit iiios Storage Management
 
Unit 1os processes and threads
Unit 1os processes and threadsUnit 1os processes and threads
Unit 1os processes and threads
 

Recently uploaded

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
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
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
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
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
 
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
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 

Recently uploaded (20)

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
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
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...
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
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
 
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
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
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
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 

Unit ii

  • 1.
  • 2. Structure Definitions struct time { int hour; int min; int second; } Accessing members of structure time t; cout<<t.hour; time * timeptr; Using pointers timeptr = &t; cout<<timeptr->hour; (*timeptr).hour; Example
  • 3. Classes and Objects  A class can be described as a collection of data members and member functions.  Functions are called member functions and define a set of operations that can be performed on the data members of the class.  The association of data and member functions are called encapsulation.
  • 4.
  • 5. Class objects  The process of creating objects(variables) of the class is called class instantiation. Necessary resources are allocated only when the class is instantiated.  The syntax is as follows:  Class className ObjectName…..  Ex: class student s1;
  • 6. Accessing Class members  Class members are accessed using member access operator , dot(.)  Syntax : ObjectName.Datamember;  Example: Student s1;  s1.rollno;  s1.printdetails();
  • 7. Defining member functions  Member functions of the class can be defined in any one of the following ways  Inside the class specification  Outside the class specification
  • 8. Member functions outside the class body Example
  • 9. Access specifiers  Private: The private members of a class have strict access control. Only the member functions of the same class can access these members. It prevents accidental modifications of the data members. class person { private: int age; int getage(); }; Person p1; p1.age = 10; // cannot access private data p1.getage(); // cannot access private function
  • 10. Public members  The members of a class which are visible outside the class are declared in public section. class person { public: int age; int getage(); }; Person p1; p1.age = 10; // can access public datat p1.getage(); // can access public function
  • 11. Protected members  The access control of protected members is similar to private members and has significance to inheritance.  Empty classes;  Class xyz{};  Class Empty {};
  • 12. Constructors and Destructors  Constructors:  The constructor gets called automatically for each object that has just got created.  It appears as member function of each class, whether defined or not.  It has same name as the class. It may or may not take parameters .  It does not return anything  The prototype is  Class name(parameter list);  Example
  • 13. Parameterized constructors  Constructors with arguments are called parameterized constructors. Example
  • 14. Dynamic memory Operators new and new[] The new operator offers dynamic storage allocation similar to the standard library function malloc. Throws an exception when memory allocation fails. pointer = new type pointer = new type [number_of_elements] int * b; b = new int [5]; Operators delete and delete[] delete pointer; delete [] pointer;  Example
  • 15. Destructor  When an object is no longer needed it can be destroyed. A class can have a member function called destructor which is invoked when an object is destroyed. Example
  • 17.  Constructors with dynamic operations  Example 2
  • 19.  The copy constructor is a special type of parameterized constructor.  It copies one object to another.  It can be called when an object is created and equated to an existing object at the same time.  Vector v1(5), v2(5);  v1= v2; // operator = invoked  vector v3 = v2; // copy constructor is invoked.  Vector v3(v2)  vector *ptr = new vector(v1);
  • 20. Passing Objects as Arguments  Methods  Pass by value  Example  Pass and return by reference  Example  Array of objects
  • 21. this pointer  The this pointer points at the object with respect to which the function was called.  this pointer is always a constant pointer.  The compiler converts the class into a structure with only data members. class dist { int feet,inch; public: int getfeet(); int getinch(); } struct dist { int feet, inch; }; int getfeet(dist * const); int getinch(dist * const);
  • 22. int dist::getfeet() { Return feet; } int getfeet(dist * const this) { return this->feet; }
  • 23. OPERATOR OVERLOADING  Operator overloading feature of C++ is one of the methods of realizing polymorphism.  Operator overloading helps in  Extending capability of operators to operate on user defined data.  Data conversion  Operator overloading extends the semantics of an operator without changing its syntax.
  • 24.
  • 25. Unary operator overloading  Example with member function  Example with operator overloading  Operator keyword  The keyword operator facilitates overloading of the C++ operators.
  • 26. Operator return values  idx1 = idx2++;  Example  Binary Operator overloading
  • 27. Arithmetic operators  Adding two objects of a class  Direct Addition  Overloaded + operator  String Example
  • 28. Comparison operators  Example  Arithmetic assignment operators
  • 31. Conversion between objects of different classes.  ClassA objecta;  ClassB objectb;  objecta = objectb;  Conversion routine in the source object’s class is implemented using an operator function  In objecta= objectb, objectb is the source object of classB
  • 32. Conversion between objects of different classes.  Example
  • 33. Conversion routine in destination object: Constructor function  Example
  • 34. Overloading with friend functions Example Example 2
  • 35. Inheritance  Inheritance is a technique of organizing information in a hierarchical form.  Inheritance allows new classes to be built from older and less specialized class.  Classes are created by first inheriting all the variables and behavior defined by some primitive class and then adding specialized variables and behaviors.  Inheritance allows code reusability.
  • 36.
  • 37. Base class and derived class
  • 38.
  • 41.
  • 42.
  • 43. Constructors Zero argument constructor in base and derived class Example Parameterized constructors in base and derived classes Example Parameterized constructor in derived class Example
  • 44. Multilevel Inheritance  Derivation of a class from another derived class is called multilevel inheritance.  Example  Constructor Example
  • 47. Multipath Inheritance  The form of inheritance which derives a new class by multiple inheritance of base classes, which are derived earlier form the same base class is known as multipath inheritance.  Example
  • 48.  Problems with multipath inheritance:  Ambiguity due to duplicate copies of members inherited from the base class.  Virtual Base class is used to solve the ambiguity issue in multipath inheritance.
  • 50.  Write a program to implement hybrid inheritance shown in the diagram. Consider necessary details for all the classes.