SlideShare a Scribd company logo
1 of 39
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
OPPS using
C++ BCA – III
Paper Code 209
Unit-1
Object oriented programming
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• Object Oriented Programming (OOP) is an
approach to program organization and
development that attempts to eliminate some
of the pitfalls of conventional programming
methods by incorporating the best of
structured programming features with several
powerful new concepts.
Procedure-Oriented Programming
Procedure oriented programming basically
consists of writing a list of instructions for the
computer to follow, and organizing these
instructions into groups known as functions.
We normally use flowcharts to organize these
actions and represent the flow of control from
one action to another
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Characteristics of POP
• Emphasis is on doing things (algorithms).
• Large programs are divided into smaller programs
known as functions.
• Most of the functions share global data.
• Data move openly around the system from function
to function.
• Functions transform data from one form to another.
• Employs top-down approach in program design
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Characteristics of OOPS
• Emphasis is on data rather than procedure.
• Programs are divided into what are known as objects.
• Data structures are designed such that they characterize the objects.
• Functions that operate on the data of an object are ties together in the
data structure.
• Data is hidden and cannot be accessed by external function.
• Objects may communicate with each other through function.
• New data and functions can be easily added whenever necessary.
• Follows bottom up approach in program design.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Features of OOPs
• Objects
• Classes
• Data abstraction and encapsulation
• Inheritance
• Polymorphism
• Dynamic binding
• Message passing
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Features of OOPs
• Objects
• Classes
• Data abstraction and encapsulation
• Inheritance
• Polymorphism
• Dynamic binding
• Message passing
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Introduction of C++
• What is C++?
• Applications of C++.
• Simple Program Features.
• Comments
• Output Operator
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• Header Files
• Return Type of main
• More C++ Statements
• An example With Class
• Structure of C++ Program
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• It is an object oriented programming.
• It is the super set of c.
• It has bottom-up approach.
• Applications:-
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
•#include< iostream.h >
#include< conio.h >
int main( )
{
cout<<
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• Input & Output Operator
• The operator >> is called the extraction
operator. It is used for output.
• The operator << is known as insertion
operator. It is used for input .
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
OPPS using
C++ BCA – III
Paper Code 209
Unit-2
Definition and declaration of class
• Class Tag Name
• Data member
• Member Function Program Access Level
a) Private
b) Public
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Class Definition
A class in C++ combines related data and functions
together. It makes a data type which is used for
creating objects of this type. Classes represent real
world entities that have both data type properties
(characteristics) and associated operations
(behavior).
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Class structure
• Class name_of _class
• { private : variable declaration;
// data member Function declaration;
// Member Function (Method) protected:
Variable declaration;
Function declaration; public
: variable declaration;
Function declaration; };
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Classes in C++
• Within the body, the keywords private: and
public: specify the access level of the
members of the class.
– the default is private.
• Usually, the data members of a class are
declared in the private: section of the class
and the member functions are in public:
section.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Creating Object
• Declaring a variable of a class type creates an object.
You can have many variables of the same type (class).
– Instantiation
• Once an object of a certain class is instantiated, a
new memory location is created for it to store its
data members and code
• You can instantiate many objects from a class type.
– Ex) Circle c; Circle *c;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Special Member Functions
• Constructor:
– Public function member
– called when a new object is created (instantiated).
– Initialize data members.
– Same name as class
– No return type
– Several constructors
• Function overloading
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• class Circle
• {
• private:
• double radius;
• public:
• Circle();
• Circle(int r);
• void setRadius(double r);
• double getDiameter();
• double getArea();
• double getCircumference();
• };
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
OPPS using
C++ BCA – III
Paper Code 209
Unit-3
Destructors
It is an object oriented programming.
• It is the super set of c.
• It has bottom-up approach.
• Applications:- Destructors
– Special member function
– Same name as class
• Preceded with tilde (~)
– No arguments
– No return value
– Cannot be overloaded
– Before system reclaims object’s memory
• Reuse memory for new objects
• Mainly used to de-allocate dynamic memory locations
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• STATIC CLASS MEMBERS
Data members and member functions of a
class in C++, may be qualified as static. We can
have static data members and static member
function in a class.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
• A friend function of a class is defined outside
that class' scope but it has the right to access
all private and protected members of the
class. Even though the prototypes for friend
functions appear in the class
definition, friendsare not member functions.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Inline functions
• An inline functions to reduce the function call
overhead. Inline function is a function that is
expanded in line when it is called. When the
inline function is called whole code of the
inline function gets inserted or substituted at
the point of inline function call. This
substitution is performed by the C++ compiler
at compile time. Inline function may increase
efficiency if it is small.
• inline return-type function-name(parameters)
{ // function code }
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
OPPS using
C++ BCA – III
Paper Code 209
Unit-4
Templates
• Type-independent patterns that can
work with multiple data types.
– Generic programming
– Code reusable
• Function Templates
– These define logic behind the algorithms
that work for multiple data types.
• Class Templates
–Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Function and function templates
}
• C++ routines work on specific types. We
often need to write different routines to
perform the same operation on different
data types.
int maximum(int a, int b, int c)
{
int max = a;
if (b > max) max = b; if (c >
max) max = c;
return max;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d6ia)
Function and function templates
float maximum(float a, float b, float c)
{
float max = a;
if (b > max) max = b;
if (c > max) max = c;
return max;
}
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d7ia)
Function and function templates
double maximum(double a,
double b, double c)
{
double max = a;
if (b > max) max = b;
if (c > max) max = c;
return max;
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d8ia)
Function Templates
• Generic function to find a maximum value
(see maximum example).
Template <class T>
T maximum(T a, T b, T c)
{
T max = a;
if (b > max) max = b;
if (c > max) max = c;
return max;
}
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d9ia)
Function Templates Usage
• After a function template is included (or defined),
the function can be used by passing parameters of
real types.
Template <class T>
T maximum(T a, T b, T c)
…
int i1, i2, i3;
…
Int m = maximum(i1, i2,i3);
• maximum(i1, i2, i3) will invoke the template function with T==int. The function
returns a value of int type.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIn3d0ia)
Function Templates Usage
• Each call to maximum() on a different data type
forces the compiler to generate a different
function using the template. See the maximum
example.
– One copy of code for many types.
int i1, i2, i3;
// invoke int version of maximum
cout << "The maximum integer value is: "
<< maximum( i1, i2, i3 );
// demonstrate maximum with double values
double d1, d2, d3;
// invoke double version of maximum
cout << "The maximum double value is: "
<< maximum( d1, d2, d3 );
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
Another example
template< class T >
void printArray( const T *array, const int count )
{
for ( int i = 0; i < count; i++ )
cout << array[ i ] << " "; cout << endl;
}
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d2ia)
Class template
• So far the classes that we define use fix data
types.
• Sometime is useful to allow storage in a class
for different data types.
• See simplelist1 (a list of int type elements)
example
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
Class template
– Function templates allow writing generic functions
that work on many types.
– Same idea applies to defining generic classes that
work with many types -- extract the type to be a
template to make a generic classes.
– See simplelist3
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
Class template
• To make a class into a template, prefix the class definition with the syntax:
template< class T >
– Here T is just a type parameter. Like a function parameter, it is a
place holder.
– When the class is instantiated, T is replaced by a real type.
• To access a member function, use the following syntax:
– className< T >:: memberName.
• Usi
–
– SimpleList < T > :: SimpleList()
Chanderprabhu Jain College of Higher Studies & School of
Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council
of In d ia)
Exception handling
• Exceptions
– Indicate problems that occur during a program’s
execution
– Occur infrequently
• Exception handling
– Can resolve exceptions
• Allow a program to continue executing or
• Notify the user of the problem and
• Terminate the program in a controlled manner
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi –110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)

More Related Content

What's hot

OPPS using C++
OPPS using C++ OPPS using C++
OPPS using C++ cpjcollege
 
FRONT END DESIGN TOOL VB.NET
FRONT END DESIGN TOOL VB.NET FRONT END DESIGN TOOL VB.NET
FRONT END DESIGN TOOL VB.NET cpjcollege
 
Computer Applications
Computer ApplicationsComputer Applications
Computer Applicationscpjcollege
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )cpjcollege
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)cpjcollege
 
Principles of accounting BCAbca 207
Principles of accounting BCAbca 207Principles of accounting BCAbca 207
Principles of accounting BCAbca 207cpjcollege
 
Production Management & Total Quality Management
Production Management & Total Quality ManagementProduction Management & Total Quality Management
Production Management & Total Quality Managementcpjcollege
 
Managerial Personality Development
Managerial Personality DevelopmentManagerial Personality Development
Managerial Personality Developmentcpjcollege
 
Management Information system
Management Information systemManagement Information system
Management Information systemcpjcollege
 
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...IJAAS Team
 
E learning companies - linkedin
E learning companies - linkedinE learning companies - linkedin
E learning companies - linkedinVijay Kothari
 
08 8879 10060-1-sm (ijict sj) edit iqbal
08 8879 10060-1-sm (ijict sj) edit iqbal08 8879 10060-1-sm (ijict sj) edit iqbal
08 8879 10060-1-sm (ijict sj) edit iqbalIAESIJEECS
 
Organisational Behaviour
Organisational BehaviourOrganisational Behaviour
Organisational Behaviourcpjcollege
 
Business Economics
Business EconomicsBusiness Economics
Business Economicscpjcollege
 
Business Economics
Business EconomicsBusiness Economics
Business Economicscpjcollege
 
Business environment
Business environment Business environment
Business environment cpjcollege
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecturecpjcollege
 
Firstobject e-education credentials
Firstobject e-education credentialsFirstobject e-education credentials
Firstobject e-education credentialsFirstobject
 

What's hot (19)

OPPS using C++
OPPS using C++ OPPS using C++
OPPS using C++
 
FRONT END DESIGN TOOL VB.NET
FRONT END DESIGN TOOL VB.NET FRONT END DESIGN TOOL VB.NET
FRONT END DESIGN TOOL VB.NET
 
Computer Applications
Computer ApplicationsComputer Applications
Computer Applications
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )
 
Normalization
NormalizationNormalization
Normalization
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)
 
Principles of accounting BCAbca 207
Principles of accounting BCAbca 207Principles of accounting BCAbca 207
Principles of accounting BCAbca 207
 
Production Management & Total Quality Management
Production Management & Total Quality ManagementProduction Management & Total Quality Management
Production Management & Total Quality Management
 
Managerial Personality Development
Managerial Personality DevelopmentManagerial Personality Development
Managerial Personality Development
 
Management Information system
Management Information systemManagement Information system
Management Information system
 
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...
Angular Symmetric Axis Constellation Model for Off-line Odia Handwritten Char...
 
E learning companies - linkedin
E learning companies - linkedinE learning companies - linkedin
E learning companies - linkedin
 
08 8879 10060-1-sm (ijict sj) edit iqbal
08 8879 10060-1-sm (ijict sj) edit iqbal08 8879 10060-1-sm (ijict sj) edit iqbal
08 8879 10060-1-sm (ijict sj) edit iqbal
 
Organisational Behaviour
Organisational BehaviourOrganisational Behaviour
Organisational Behaviour
 
Business Economics
Business EconomicsBusiness Economics
Business Economics
 
Business Economics
Business EconomicsBusiness Economics
Business Economics
 
Business environment
Business environment Business environment
Business environment
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Firstobject e-education credentials
Firstobject e-education credentialsFirstobject e-education credentials
Firstobject e-education credentials
 

Similar to C++ OOP concepts explained including classes, objects, constructors and destructors

JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING cpjcollege
 
Introduction To Database Management System
Introduction To Database Management SystemIntroduction To Database Management System
Introduction To Database Management Systemcpjcollege
 
Introduction to VB Programming
Introduction to VB ProgrammingIntroduction to VB Programming
Introduction to VB Programmingcpjcollege
 
Software Testing
Software Testing Software Testing
Software Testing cpjcollege
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineeringcpjcollege
 
SOFTWARE ENGINEERING
SOFTWARE ENGINEERING SOFTWARE ENGINEERING
SOFTWARE ENGINEERING cpjcollege
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineeringcpjcollege
 
Linux environment
Linux environment Linux environment
Linux environment cpjcollege
 
Management & Cost Accounting
Management & Cost AccountingManagement & Cost Accounting
Management & Cost Accountingcpjcollege
 
Management Information System
Management Information SystemManagement Information System
Management Information Systemcpjcollege
 
Digital electronics
Digital electronicsDigital electronics
Digital electronicscpjcollege
 
Management Process And Organisation Behaviour
Management Process And Organisation BehaviourManagement Process And Organisation Behaviour
Management Process And Organisation Behaviourcpjcollege
 
Management Process & Organizational Behavior
Management Process & Organizational Behavior Management Process & Organizational Behavior
Management Process & Organizational Behavior cpjcollege
 
Introduction to IT
Introduction to ITIntroduction to IT
Introduction to ITcpjcollege
 
Computer Applications
Computer ApplicationsComputer Applications
Computer Applicationscpjcollege
 
DBMS presentation
DBMS presentationDBMS presentation
DBMS presentationcpjcollege
 
Information Systems Management
Information Systems Management Information Systems Management
Information Systems Management cpjcollege
 
Principles of Management
Principles of ManagementPrinciples of Management
Principles of Managementcpjcollege
 
Principles of Management
Principles of ManagementPrinciples of Management
Principles of Managementcpjcollege
 

Similar to C++ OOP concepts explained including classes, objects, constructors and destructors (20)

JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Introduction To Database Management System
Introduction To Database Management SystemIntroduction To Database Management System
Introduction To Database Management System
 
Introduction to VB Programming
Introduction to VB ProgrammingIntroduction to VB Programming
Introduction to VB Programming
 
Software Testing
Software Testing Software Testing
Software Testing
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
SOFTWARE ENGINEERING
SOFTWARE ENGINEERING SOFTWARE ENGINEERING
SOFTWARE ENGINEERING
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Linux environment
Linux environment Linux environment
Linux environment
 
Management & Cost Accounting
Management & Cost AccountingManagement & Cost Accounting
Management & Cost Accounting
 
Management Information System
Management Information SystemManagement Information System
Management Information System
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Management Process And Organisation Behaviour
Management Process And Organisation BehaviourManagement Process And Organisation Behaviour
Management Process And Organisation Behaviour
 
Management Process & Organizational Behavior
Management Process & Organizational Behavior Management Process & Organizational Behavior
Management Process & Organizational Behavior
 
Introduction to IT
Introduction to ITIntroduction to IT
Introduction to IT
 
Computer Applications
Computer ApplicationsComputer Applications
Computer Applications
 
DBMS presentation
DBMS presentationDBMS presentation
DBMS presentation
 
PDCS II
PDCS IIPDCS II
PDCS II
 
Information Systems Management
Information Systems Management Information Systems Management
Information Systems Management
 
Principles of Management
Principles of ManagementPrinciples of Management
Principles of Management
 
Principles of Management
Principles of ManagementPrinciples of Management
Principles of Management
 

More from cpjcollege

Tax Law (LLB-403)
Tax Law (LLB-403)Tax Law (LLB-403)
Tax Law (LLB-403)cpjcollege
 
Law and Emerging Technology (LLB -405)
 Law and Emerging Technology (LLB -405) Law and Emerging Technology (LLB -405)
Law and Emerging Technology (LLB -405)cpjcollege
 
Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205) cpjcollege
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )cpjcollege
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201) cpjcollege
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] cpjcollege
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303) cpjcollege
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)cpjcollege
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)cpjcollege
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)cpjcollege
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]cpjcollege
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)cpjcollege
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)cpjcollege
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)cpjcollege
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)cpjcollege
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )cpjcollege
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)cpjcollege
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )cpjcollege
 
CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }cpjcollege
 
Economics-I (BALLB 207)
Economics-I (BALLB 207)Economics-I (BALLB 207)
Economics-I (BALLB 207)cpjcollege
 

More from cpjcollege (20)

Tax Law (LLB-403)
Tax Law (LLB-403)Tax Law (LLB-403)
Tax Law (LLB-403)
 
Law and Emerging Technology (LLB -405)
 Law and Emerging Technology (LLB -405) Law and Emerging Technology (LLB -405)
Law and Emerging Technology (LLB -405)
 
Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205)
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201)
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309]
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303)
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 
CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }
 
Economics-I (BALLB 207)
Economics-I (BALLB 207)Economics-I (BALLB 207)
Economics-I (BALLB 207)
 

Recently uploaded

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 

Recently uploaded (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 

C++ OOP concepts explained including classes, objects, constructors and destructors

  • 1. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) OPPS using C++ BCA – III Paper Code 209 Unit-1
  • 2. Object oriented programming Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia) • Object Oriented Programming (OOP) is an approach to program organization and development that attempts to eliminate some of the pitfalls of conventional programming methods by incorporating the best of structured programming features with several powerful new concepts.
  • 3. Procedure-Oriented Programming Procedure oriented programming basically consists of writing a list of instructions for the computer to follow, and organizing these instructions into groups known as functions. We normally use flowcharts to organize these actions and represent the flow of control from one action to another Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 4. Characteristics of POP • Emphasis is on doing things (algorithms). • Large programs are divided into smaller programs known as functions. • Most of the functions share global data. • Data move openly around the system from function to function. • Functions transform data from one form to another. • Employs top-down approach in program design Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 5. Characteristics of OOPS • Emphasis is on data rather than procedure. • Programs are divided into what are known as objects. • Data structures are designed such that they characterize the objects. • Functions that operate on the data of an object are ties together in the data structure. • Data is hidden and cannot be accessed by external function. • Objects may communicate with each other through function. • New data and functions can be easily added whenever necessary. • Follows bottom up approach in program design. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 6. Features of OOPs • Objects • Classes • Data abstraction and encapsulation • Inheritance • Polymorphism • Dynamic binding • Message passing Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 7. Features of OOPs • Objects • Classes • Data abstraction and encapsulation • Inheritance • Polymorphism • Dynamic binding • Message passing Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 8. Introduction of C++ • What is C++? • Applications of C++. • Simple Program Features. • Comments • Output Operator Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 9. • Header Files • Return Type of main • More C++ Statements • An example With Class • Structure of C++ Program Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 10. • It is an object oriented programming. • It is the super set of c. • It has bottom-up approach. • Applications:- Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 11. •#include< iostream.h > #include< conio.h > int main( ) { cout<< Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 12. • Input & Output Operator • The operator >> is called the extraction operator. It is used for output. • The operator << is known as insertion operator. It is used for input . Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 13. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) OPPS using C++ BCA – III Paper Code 209 Unit-2
  • 14. Definition and declaration of class • Class Tag Name • Data member • Member Function Program Access Level a) Private b) Public Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 15. Class Definition A class in C++ combines related data and functions together. It makes a data type which is used for creating objects of this type. Classes represent real world entities that have both data type properties (characteristics) and associated operations (behavior). Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 16. Class structure • Class name_of _class • { private : variable declaration; // data member Function declaration; // Member Function (Method) protected: Variable declaration; Function declaration; public : variable declaration; Function declaration; }; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 17. Classes in C++ • Within the body, the keywords private: and public: specify the access level of the members of the class. – the default is private. • Usually, the data members of a class are declared in the private: section of the class and the member functions are in public: section. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 18. Creating Object • Declaring a variable of a class type creates an object. You can have many variables of the same type (class). – Instantiation • Once an object of a certain class is instantiated, a new memory location is created for it to store its data members and code • You can instantiate many objects from a class type. – Ex) Circle c; Circle *c; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 19. Special Member Functions • Constructor: – Public function member – called when a new object is created (instantiated). – Initialize data members. – Same name as class – No return type – Several constructors • Function overloading Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 20. • class Circle • { • private: • double radius; • public: • Circle(); • Circle(int r); • void setRadius(double r); • double getDiameter(); • double getArea(); • double getCircumference(); • }; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 21. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) OPPS using C++ BCA – III Paper Code 209 Unit-3
  • 22. Destructors It is an object oriented programming. • It is the super set of c. • It has bottom-up approach. • Applications:- Destructors – Special member function – Same name as class • Preceded with tilde (~) – No arguments – No return value – Cannot be overloaded – Before system reclaims object’s memory • Reuse memory for new objects • Mainly used to de-allocate dynamic memory locations Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 23. • STATIC CLASS MEMBERS Data members and member functions of a class in C++, may be qualified as static. We can have static data members and static member function in a class. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 24. • A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friendsare not member functions. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 25. Inline functions • An inline functions to reduce the function call overhead. Inline function is a function that is expanded in line when it is called. When the inline function is called whole code of the inline function gets inserted or substituted at the point of inline function call. This substitution is performed by the C++ compiler at compile time. Inline function may increase efficiency if it is small.
  • 26. • inline return-type function-name(parameters) { // function code } Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 27. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) OPPS using C++ BCA – III Paper Code 209 Unit-4
  • 28. Templates • Type-independent patterns that can work with multiple data types. – Generic programming – Code reusable • Function Templates – These define logic behind the algorithms that work for multiple data types. • Class Templates –Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 29. Function and function templates } • C++ routines work on specific types. We often need to write different routines to perform the same operation on different data types. int maximum(int a, int b, int c) { int max = a; if (b > max) max = b; if (c > max) max = c; return max; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d6ia)
  • 30. Function and function templates float maximum(float a, float b, float c) { float max = a; if (b > max) max = b; if (c > max) max = c; return max; } Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d7ia)
  • 31. Function and function templates double maximum(double a, double b, double c) { double max = a; if (b > max) max = b; if (c > max) max = c; return max; Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d8ia)
  • 32. Function Templates • Generic function to find a maximum value (see maximum example). Template <class T> T maximum(T a, T b, T c) { T max = a; if (b > max) max = b; if (c > max) max = c; return max; } Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In2d9ia)
  • 33. Function Templates Usage • After a function template is included (or defined), the function can be used by passing parameters of real types. Template <class T> T maximum(T a, T b, T c) … int i1, i2, i3; … Int m = maximum(i1, i2,i3); • maximum(i1, i2, i3) will invoke the template function with T==int. The function returns a value of int type. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIn3d0ia)
  • 34. Function Templates Usage • Each call to maximum() on a different data type forces the compiler to generate a different function using the template. See the maximum example. – One copy of code for many types. int i1, i2, i3; // invoke int version of maximum cout << "The maximum integer value is: " << maximum( i1, i2, i3 ); // demonstrate maximum with double values double d1, d2, d3; // invoke double version of maximum cout << "The maximum double value is: " << maximum( d1, d2, d3 ); Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
  • 35. Another example template< class T > void printArray( const T *array, const int count ) { for ( int i = 0; i < count; i++ ) cout << array[ i ] << " "; cout << endl; } Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d2ia)
  • 36. Class template • So far the classes that we define use fix data types. • Sometime is useful to allow storage in a class for different data types. • See simplelist1 (a list of int type elements) example Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
  • 37. Class template – Function templates allow writing generic functions that work on many types. – Same idea applies to defining generic classes that work with many types -- extract the type to be a template to make a generic classes. – See simplelist3 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)
  • 38. Class template • To make a class into a template, prefix the class definition with the syntax: template< class T > – Here T is just a type parameter. Like a function parameter, it is a place holder. – When the class is instantiated, T is replaced by a real type. • To access a member function, use the following syntax: – className< T >:: memberName. • Usi – – SimpleList < T > :: SimpleList() Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In d ia)
  • 39. Exception handling • Exceptions – Indicate problems that occur during a program’s execution – Occur infrequently • Exception handling – Can resolve exceptions • Allow a program to continue executing or • Notify the user of the problem and • Terminate the program in a controlled manner Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi –110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of In3d1ia)