SlideShare a Scribd company logo
Prepared By: Asst. Prof. Sejal Jadav
Unit-1
Principles of Object Oriented Programming Tokens,
expressions & Control Statements
(14 MARKS)
B.C.A & B.Sc.(IT) – 3
CS-13 C++ and Object Oriented
Programming
Prepared By: Asst. Prof. Sejal Jadav
Operators
• Input/output operators
• << output / insertion operator
• >> input / extraction operator
• Scope resolution operator
• ::
• Memory management operators
• New-memory allocation
operator
• Delete-memory release operator
• Member dereferencing operator
• ::* pointer-to-member declarator
• ->*pointer-to-member operator
• .* pointer-to-member operator
• Manipulators
• Endl-line feed operator
• Setw-field width operator
• Type cast operator
• Definition : An operator is a symbol that tells the compiler to
perform specific mathematical or logical manipulations.
Prepared By: Asst. Prof. Sejal Jadav
Scope Resolution Operator
• We know that the same variable name can be used in
different blocks in C++
• The scope of the variable extends from the point of its
declaration till the end of the block containing the
declaration.
Prepared By: Asst. Prof. Sejal Jadav
• The variable declared inside the block is called local
variable to that block.
• While blocks are nested the declaration in inner block
hides a declaration of the same variable in an outer
block.
Prepared By: Asst. Prof. Sejal Jadav
• Hence in C – language the global variable cannot be
accessed from the inner block.
• C++ resolves this problem by introducing a new
operator : : called scope resolution operator.
Prepared By: Asst. Prof. Sejal Jadav
Syntax :
: : variable_name
• This operator allows global version of the variable.
• Let’s see Example……. 12_scope_operator.cpp
Prepared By: Asst. Prof. Sejal Jadav
Type cast operator
• Type casting is a way to convert a variable
from one data type to another datatype.
• For example, if you want to store a long value into a
simple integer then you can typecast long to int.
• You can convert values from one type to another
explicitly using the cast operator.
Prepared By: Asst. Prof. Sejal Jadav
•There are two types of type conversion in C++.
1. Implicit Conversion
2. Explicit Conversion (also known as Type
Casting)
Prepared By: Asst. Prof. Sejal Jadav
Implicit Type Conversion
• The type conversion that is done automatically done
by the compiler is known as implicit type conversion.
• This type of conversion is also known as automatic
conversion.
• Let’s look at examples: 01_typecast, 02_typecast.cpp
Prepared By: Asst. Prof. Sejal Jadav
int main() {
int num_int = 9;
double num_double;
num_double = num_int;
cout << "num_int = " << num_int << endl;
cout << "num_double = " << num_double << endl;
}
Output
num_int = 9
num_double = 9
Prepared By: Asst. Prof. Sejal Jadav
• In the program, we have assigned an int data to a
double variable.
num_double = num_int;
• Here, the int value is automatically converted to
double by the compiler before it is assigned to the
num_double variable. This is an example of implicit
type conversion.
Prepared By: Asst. Prof. Sejal Jadav
Data Loss During Conversion (Narrowing Conversion)
• As we have seen from the above example, conversion
from one data type to another is to data loss.
• This happens when data of a larger type is converted
to data of a smaller type.
Prepared By: Asst. Prof. Sejal Jadav
Prepared By: Asst. Prof. Sejal Jadav
C++ Explicit Conversion
• When the user manually changes data from one type
to another, this is known as explicit conversion.
• This type of conversion is also known as type
casting.
Prepared By: Asst. Prof. Sejal Jadav
• There are three major ways in which we can use
explicit conversion in C++. They are:
1. C-style type casting (also known as cast notation)
2. Function notation (also known as old C++ style
type casting)
3. Type conversion operators
Prepared By: Asst. Prof. Sejal Jadav
C-style Type Casting
• As the name suggests, this type of casting is favored
by the C programming language. It is also known as
cast notation.
• The syntax for this style is:
(data_type)expression;
Prepared By: Asst. Prof. Sejal Jadav
For example,
// initializing int variable
int num_int = 26;
// declaring double variable
double num_double;
// converting from int to double
num_double = (double)num_int;
Prepared By: Asst. Prof. Sejal Jadav
Function-style Casting
• We can also use the function like notation to cast data
from one type to another.
• The syntax for this style is:
data_type(expression);
Prepared By: Asst. Prof. Sejal Jadav
For example,
// initializing int variable
int num_int = 26;
// declaring double variable
double num_double;
// converting from int to double
num_double = double(num_int);

More Related Content

What's hot

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
246paa
 
Object oriented programming 2 elements of programming
Object oriented programming 2 elements of programmingObject oriented programming 2 elements of programming
Object oriented programming 2 elements of programming
Vaibhav Khanna
 
#6- Arrays and Collections Framework
#6- Arrays and Collections Framework#6- Arrays and Collections Framework
#6- Arrays and Collections Framework
Ghadeer AlHasan
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Pavith Gunasekara
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
DINESH KUMAR ARIVARASAN
 
OOPS features using Objective C
OOPS features using Objective COOPS features using Objective C
OOPS features using Objective C
Tiyasi Acharya
 
Practice Session
Practice Session Practice Session
Practice Session
Hitesh-Java
 
4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading
Ghadeer AlHasan
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPs
Essay Corp
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
baabtra.com - No. 1 supplier of quality freshers
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introduction
sandeep54552
 
Constructor and Destructors in C++
Constructor and Destructors in C++Constructor and Destructors in C++
Constructor and Destructors in C++
sandeep54552
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
Michael Heron
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
Tushar B Kute
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
HDR1001
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Keyur Vadodariya
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
Ajit Nayak
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1stConnex
 

What's hot (20)

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Object oriented programming 2 elements of programming
Object oriented programming 2 elements of programmingObject oriented programming 2 elements of programming
Object oriented programming 2 elements of programming
 
#6- Arrays and Collections Framework
#6- Arrays and Collections Framework#6- Arrays and Collections Framework
#6- Arrays and Collections Framework
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
 
OOPS features using Objective C
OOPS features using Objective COOPS features using Objective C
OOPS features using Objective C
 
Practice Session
Practice Session Practice Session
Practice Session
 
4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading4- Inheritance, Aggregation, Encapsulation and Overloading
4- Inheritance, Aggregation, Encapsulation and Overloading
 
Concepts of OOPs
Concepts of OOPsConcepts of OOPs
Concepts of OOPs
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
 
C++ programming introduction
C++ programming introductionC++ programming introduction
C++ programming introduction
 
Constructor and Destructors in C++
Constructor and Destructors in C++Constructor and Destructors in C++
Constructor and Destructors in C++
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
JavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat SheetJavaScript Object Oriented Programming Cheat Sheet
JavaScript Object Oriented Programming Cheat Sheet
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 
Lecture02
Lecture02Lecture02
Lecture02
 
class and objects
class and objectsclass and objects
class and objects
 
Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
 

Similar to C++ unit-1-part-9

C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
Jadavsejal
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7
Jadavsejal
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
Thapar Institute
 
Aspdot
AspdotAspdot
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
SURBHI SAROHA
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
sunila tharagaturi
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12
Jadavsejal
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
sophoeutsen2
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
shashikant pabari
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
Ralph Weber
 
C programming
C programming C programming
C programming
AsifRahaman16
 
C programming language
C programming languageC programming language
C programming language
Abin Rimal
 
Session 06 - Java Basics
Session 06 - Java BasicsSession 06 - Java Basics
Session 06 - Java Basics
SiddharthSelenium
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
8759000398
 
Data structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in CData structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in C
babuk110
 

Similar to C++ unit-1-part-9 (20)

C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
C++ unit-1-part-7
C++ unit-1-part-7C++ unit-1-part-7
C++ unit-1-part-7
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
 
Aspdot
AspdotAspdot
Aspdot
 
C programming language tutorial
C programming language tutorialC programming language tutorial
C programming language tutorial
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
C++ unit-1-part-12
C++ unit-1-part-12C++ unit-1-part-12
C++ unit-1-part-12
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
Embedded _c_
Embedded  _c_Embedded  _c_
Embedded _c_
 
C programming
C programming C programming
C programming
 
C programming language
C programming languageC programming language
C programming language
 
Session 06 - Java Basics
Session 06 - Java BasicsSession 06 - Java Basics
Session 06 - Java Basics
 
Basics of C.ppt
Basics of C.pptBasics of C.ppt
Basics of C.ppt
 
Data structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in CData structure & Algorithms - Programming in C
Data structure & Algorithms - Programming in C
 

More from Jadavsejal

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone Class
Jadavsejal
 
Programming Java Concept of Event Handling
Programming Java Concept of Event HandlingProgramming Java Concept of Event Handling
Programming Java Concept of Event Handling
Jadavsejal
 
Programming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingProgramming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event Handling
Jadavsejal
 
concept of applet and concept of Layout Managers
concept of applet and concept of Layout Managersconcept of applet and concept of Layout Managers
concept of applet and concept of Layout Managers
Jadavsejal
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15
Jadavsejal
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14
Jadavsejal
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10
Jadavsejal
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8
Jadavsejal
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5
Jadavsejal
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4
Jadavsejal
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2
Jadavsejal
 
C++ unit-1-part-3
C++ unit-1-part-3C++ unit-1-part-3
C++ unit-1-part-3
Jadavsejal
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1
Jadavsejal
 
05_system architecture
05_system architecture05_system architecture
05_system architecture
Jadavsejal
 
04 data flow architecture
04 data flow architecture 04 data flow architecture
04 data flow architecture
Jadavsejal
 
Vpn protocols
Vpn protocolsVpn protocols
Vpn protocols
Jadavsejal
 
04 authentication
04 authentication04 authentication
04 authentication
Jadavsejal
 
03 cia
03 cia03 cia
03 cia
Jadavsejal
 
01
01 01
4 ipv6
4 ipv64 ipv6
4 ipv6
Jadavsejal
 

More from Jadavsejal (20)

Programming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone ClassProgramming with Java Concept: Java TimeZone Class
Programming with Java Concept: Java TimeZone Class
 
Programming Java Concept of Event Handling
Programming Java Concept of Event HandlingProgramming Java Concept of Event Handling
Programming Java Concept of Event Handling
 
Programming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event HandlingProgramming Java GUI using SWING, Event Handling
Programming Java GUI using SWING, Event Handling
 
concept of applet and concept of Layout Managers
concept of applet and concept of Layout Managersconcept of applet and concept of Layout Managers
concept of applet and concept of Layout Managers
 
C++ unit-1-part-15
C++ unit-1-part-15C++ unit-1-part-15
C++ unit-1-part-15
 
C++ unit-1-part-14
C++ unit-1-part-14C++ unit-1-part-14
C++ unit-1-part-14
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10
 
C++ unit-1-part-8
C++ unit-1-part-8C++ unit-1-part-8
C++ unit-1-part-8
 
C++ unit-1-part-5
C++ unit-1-part-5C++ unit-1-part-5
C++ unit-1-part-5
 
C++ unit-1-part-4
C++ unit-1-part-4C++ unit-1-part-4
C++ unit-1-part-4
 
C++ unit-1-part-2
C++ unit-1-part-2C++ unit-1-part-2
C++ unit-1-part-2
 
C++ unit-1-part-3
C++ unit-1-part-3C++ unit-1-part-3
C++ unit-1-part-3
 
C++-Unit-1-Part-1
C++-Unit-1-Part-1C++-Unit-1-Part-1
C++-Unit-1-Part-1
 
05_system architecture
05_system architecture05_system architecture
05_system architecture
 
04 data flow architecture
04 data flow architecture 04 data flow architecture
04 data flow architecture
 
Vpn protocols
Vpn protocolsVpn protocols
Vpn protocols
 
04 authentication
04 authentication04 authentication
04 authentication
 
03 cia
03 cia03 cia
03 cia
 
01
01 01
01
 
4 ipv6
4 ipv64 ipv6
4 ipv6
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 

C++ unit-1-part-9

  • 1. Prepared By: Asst. Prof. Sejal Jadav Unit-1 Principles of Object Oriented Programming Tokens, expressions & Control Statements (14 MARKS) B.C.A & B.Sc.(IT) – 3 CS-13 C++ and Object Oriented Programming
  • 2. Prepared By: Asst. Prof. Sejal Jadav Operators • Input/output operators • << output / insertion operator • >> input / extraction operator • Scope resolution operator • :: • Memory management operators • New-memory allocation operator • Delete-memory release operator • Member dereferencing operator • ::* pointer-to-member declarator • ->*pointer-to-member operator • .* pointer-to-member operator • Manipulators • Endl-line feed operator • Setw-field width operator • Type cast operator • Definition : An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
  • 3. Prepared By: Asst. Prof. Sejal Jadav Scope Resolution Operator • We know that the same variable name can be used in different blocks in C++ • The scope of the variable extends from the point of its declaration till the end of the block containing the declaration.
  • 4. Prepared By: Asst. Prof. Sejal Jadav • The variable declared inside the block is called local variable to that block. • While blocks are nested the declaration in inner block hides a declaration of the same variable in an outer block.
  • 5. Prepared By: Asst. Prof. Sejal Jadav • Hence in C – language the global variable cannot be accessed from the inner block. • C++ resolves this problem by introducing a new operator : : called scope resolution operator.
  • 6. Prepared By: Asst. Prof. Sejal Jadav Syntax : : : variable_name • This operator allows global version of the variable. • Let’s see Example……. 12_scope_operator.cpp
  • 7. Prepared By: Asst. Prof. Sejal Jadav Type cast operator • Type casting is a way to convert a variable from one data type to another datatype. • For example, if you want to store a long value into a simple integer then you can typecast long to int. • You can convert values from one type to another explicitly using the cast operator.
  • 8. Prepared By: Asst. Prof. Sejal Jadav •There are two types of type conversion in C++. 1. Implicit Conversion 2. Explicit Conversion (also known as Type Casting)
  • 9. Prepared By: Asst. Prof. Sejal Jadav Implicit Type Conversion • The type conversion that is done automatically done by the compiler is known as implicit type conversion. • This type of conversion is also known as automatic conversion. • Let’s look at examples: 01_typecast, 02_typecast.cpp
  • 10. Prepared By: Asst. Prof. Sejal Jadav int main() { int num_int = 9; double num_double; num_double = num_int; cout << "num_int = " << num_int << endl; cout << "num_double = " << num_double << endl; } Output num_int = 9 num_double = 9
  • 11. Prepared By: Asst. Prof. Sejal Jadav • In the program, we have assigned an int data to a double variable. num_double = num_int; • Here, the int value is automatically converted to double by the compiler before it is assigned to the num_double variable. This is an example of implicit type conversion.
  • 12. Prepared By: Asst. Prof. Sejal Jadav Data Loss During Conversion (Narrowing Conversion) • As we have seen from the above example, conversion from one data type to another is to data loss. • This happens when data of a larger type is converted to data of a smaller type.
  • 13. Prepared By: Asst. Prof. Sejal Jadav
  • 14. Prepared By: Asst. Prof. Sejal Jadav C++ Explicit Conversion • When the user manually changes data from one type to another, this is known as explicit conversion. • This type of conversion is also known as type casting.
  • 15. Prepared By: Asst. Prof. Sejal Jadav • There are three major ways in which we can use explicit conversion in C++. They are: 1. C-style type casting (also known as cast notation) 2. Function notation (also known as old C++ style type casting) 3. Type conversion operators
  • 16. Prepared By: Asst. Prof. Sejal Jadav C-style Type Casting • As the name suggests, this type of casting is favored by the C programming language. It is also known as cast notation. • The syntax for this style is: (data_type)expression;
  • 17. Prepared By: Asst. Prof. Sejal Jadav For example, // initializing int variable int num_int = 26; // declaring double variable double num_double; // converting from int to double num_double = (double)num_int;
  • 18. Prepared By: Asst. Prof. Sejal Jadav Function-style Casting • We can also use the function like notation to cast data from one type to another. • The syntax for this style is: data_type(expression);
  • 19. Prepared By: Asst. Prof. Sejal Jadav For example, // initializing int variable int num_int = 26; // declaring double variable double num_double; // converting from int to double num_double = double(num_int);