際際滷

際際滷Share a Scribd company logo
Introduction to C++
 Readings: 1.1-1.3, 1.9-1.13, 1.16-1.18, 1.21-1.22
 C++
 Bjarne Stroustrup (Bell Labs, 1979)
 started as extension to C (macros and variables)
 added new useful, features
 nowadays a language of its own
 C++ (the next thing after C, though wouldnt ++C be
more appropriate?)
Outline
Intro to C++
Object-Oriented Programming
Changes in C++
comments
variable declaration location
initialization
pointer changes
tagged structure type
enum types
bool type
Object-Oriented Programming
 First-class objects - atomic types in C
 int, float, char
 have:
 values
 sets of operations that can be applied to them
 how represented irrelevant to how they are manipulated
 Other objects - structures in C
 cannot be printed
 do not have operations associated with them (at least,
not directly)
Object-Oriented Idea
 Make all objects, whether C-defined or user-
defined, first-class objects
 For C++ structures (called classes) allow:
 functions to be associated with the class
 only allow certain functions to access the internals of
the class
 allow the user to re-define existing functions (for
example, input and output) to work on class
Classes of Objects in C++
 Classes
 similar to structures in C (in fact, you can can still use
the struct definition)
 have fields corresponding to fields of a structure in C
(similar to variables)
 have fields corresponding to functions in C (functions
that can be applied to that structure)
 some fields are accessible by everyone, some not (data
hiding)
 some fields shared by the entire class
Instances of Classes in C++
 A class in C++ is like a type in C
 Variables created of a particular class are instances
of that class
 Variables have values for fields of the class
 Class example: Student
 has name, id, gpa, etc. fields that store values
 has functions, changeGPA, addCredits, that can be
applied to instances of that class
 Instance examples: John Doe, Jane Doe
 each with their own values for the fields of the class
Comments in C++
 Can use C form of comments /* A Comment */
 Can also use // form:
 when // encountered, remainder of line ignored
 works only on that line
 Examples:
void main() {
int I; // Variable used in loops
char C; // No comment comment
Variable Declarations
 In C++, variable declarations are not restricted to
the beginnings of blocks (before any code)
 you may interleave declarations/statements as needed
 it is still good style to have declarations first
 Example
void main() {
int I = 5;
printf(Please enter J: );
int J; // Not declared at the start
scanf(%d,&J);
Counter Variables in a For Loop
 You can declare the variable(s) used in a for loop
in the initialization section of the for loop
 good when counter used in for loop only exists in for
loop (variable is throw-away)
 Example
for (int I = 0; I < 5; I++)
printf(%dn,I);
 Variable exists only during for loop (goes away
when loop ends)
Initializing Global Variables
 Not restricted to using constant literal values in
initializing global variables, can use any evaluable
expression
 Example:
int rows = 5;
int cols = 6;
int size = rows * cols;
void main() {
...
Initializing Array Elements
 When giving a list of initial array values in C++,
you can use expressions that have to be evaluated
 Values calculated at run-time before initialization
done
 Example:
void main() {
int n1, n2, n3;
int *nptr[] = { &n1, &n2, &n3 };
void*
 In C it is legal to cast other pointers to and from a
void *
 In C++ this is an error, to cast you should use an
explicit casting command
 Example:
int N;
int *P = &N;
void *Q = P; // illegal in C++
void *R = (void *) P; // ok
NULL in C++
 C++ does not use the value NULL, instead NULL
is always 0 in C++, so we simply use 0
 Example:
int *P = 0; // equivalent to
// setting P to NULL
 Can check for a 0 pointer as if true/false:
if (!P) // P is 0 (NULL)
...
else // P is not 0 (non-NULL)
...
Tags and struct
 When using struct command in C++ (and for other
tagged types), can create type using tag format and
not use tag in variable declaration:
struct MyType {
int A;
float B;
};
MyType V;
enum in C++
 Enumerated types not directly represented as
integers in C++
 certain operations that are legal in C do not work in
C++
 Example:
void main() {
enum Color { red, blue, green };
Color c = red;
c = blue;
c = 1; // Error in C++
++c; // Error in C++
bool
 C has no explicit type for true/false values
 C++ introduces type bool (later versions of C++)
 also adds two new bool literal constants true (1) and
false (0)
 Other integral types (int, char, etc.) are implicitly
converted to bool when appropriate
 non-zero values are converted to true
 zero values are converted to false
bool operations
 Operators requiring bool value(s) and producing a
bool value:
&& (And), || (Or), ! (Not)
 Relational operators (==, !=, <, >, <=, >=) produce
bool values
 Some statements expect expressions that produce
bool values:
if (boolean_expression)
while (boolean_expression)
do  while (boolean_expression)
for ( ; boolean_expression; )
Ad

Recommended

C++ Introduction
C++ Introduction
parmsidhu
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
jatin batra
C_plus_plus
C_plus_plus
Ralph Weber
C++ version 1
C++ version 1
JIGAR MAKHIJA
2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++
Kuntal Bhowmick
lecture02-cpp.ppt
lecture02-cpp.ppt
MZGINBarwary
Cs1123 11 pointers
Cs1123 11 pointers
TAlha MAlik
C++ overview
C++ overview
Prem Ranjan
Presentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
Cs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
c++ ppt.ppt
c++ ppt.ppt
FarazKhan89093
C++ - A powerful and system level language
C++ - A powerful and system level language
dhimananshu130803
lecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
lecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
lecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
lecture02-cpp.ppt
lecture02-cpp.ppt
YashpalYadav46
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
NagarathnaRajur2
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
C++ Presentation
C++ Presentation
Carson Wilber
C++ language
C++ language
Hamza Asif
lecture5-cpp.pptintroduccionaC++basicoye
lecture5-cpp.pptintroduccionaC++basicoye
quetsqrj
Introduction to Inheritance in C plus plus
Introduction to Inheritance in C plus plus
University of Sindh
Data Types & Input/Output Streams.pptx Description
Data Types & Input/Output Streams.pptx Description
sachinkumar541404
L6
L6
lksoo
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
crazysamarth927
Programming Language
Programming Language
Adeel Hamid
Basic of c &c++
Basic of c &c++
guptkashish
C cpluplus 2
C cpluplus 2
sanya6900
computer networks fundamentals chapter 1
computer networks fundamentals chapter 1
Anas Abu Tabaneh [APP, ASP]
chapter01 (1).ppt
chapter01 (1).ppt
Anas Abu Tabaneh [APP, ASP]

More Related Content

Similar to C++Chapter01.PPT (20)

Presentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
Cs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
c++ ppt.ppt
c++ ppt.ppt
FarazKhan89093
C++ - A powerful and system level language
C++ - A powerful and system level language
dhimananshu130803
lecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
lecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
lecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
lecture02-cpp.ppt
lecture02-cpp.ppt
YashpalYadav46
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
NagarathnaRajur2
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
C++ Presentation
C++ Presentation
Carson Wilber
C++ language
C++ language
Hamza Asif
lecture5-cpp.pptintroduccionaC++basicoye
lecture5-cpp.pptintroduccionaC++basicoye
quetsqrj
Introduction to Inheritance in C plus plus
Introduction to Inheritance in C plus plus
University of Sindh
Data Types & Input/Output Streams.pptx Description
Data Types & Input/Output Streams.pptx Description
sachinkumar541404
L6
L6
lksoo
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
crazysamarth927
Programming Language
Programming Language
Adeel Hamid
Basic of c &c++
Basic of c &c++
guptkashish
C cpluplus 2
C cpluplus 2
sanya6900
Presentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
Cs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
C++ - A powerful and system level language
C++ - A powerful and system level language
dhimananshu130803
lecture02-cpp.ppt
lecture02-cpp.ppt
DevliNeeraj
lecture02-cpp.ppt
lecture02-cpp.ppt
ssuser0c24d5
lecture02-cpp.ppt
lecture02-cpp.ppt
nilesh405711
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
lecture NOTES ON OOPS C++ ON CLASS AND OBJECTS
NagarathnaRajur2
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
C++ language
C++ language
Hamza Asif
lecture5-cpp.pptintroduccionaC++basicoye
lecture5-cpp.pptintroduccionaC++basicoye
quetsqrj
Introduction to Inheritance in C plus plus
Introduction to Inheritance in C plus plus
University of Sindh
Data Types & Input/Output Streams.pptx Description
Data Types & Input/Output Streams.pptx Description
sachinkumar541404
L6
L6
lksoo
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
UNIT - 1- Ood ddnwkjfnewcsdkjnjkfnskfn.pptx
crazysamarth927
Programming Language
Programming Language
Adeel Hamid
Basic of c &c++
Basic of c &c++
guptkashish
C cpluplus 2
C cpluplus 2
sanya6900

More from Anas Abu Tabaneh [APP, ASP] (20)

computer networks fundamentals chapter 1
computer networks fundamentals chapter 1
Anas Abu Tabaneh [APP, ASP]
chapter01 (1).ppt
chapter01 (1).ppt
Anas Abu Tabaneh [APP, ASP]
Anas abu tabaneh cv may 2019
Anas abu tabaneh cv may 2019
Anas Abu Tabaneh [APP, ASP]
Apple teacher certificate
Apple teacher certificate
Anas Abu Tabaneh [APP, ASP]
SAMCOM TRAINING CERTIFICATE
SAMCOM TRAINING CERTIFICATE
Anas Abu Tabaneh [APP, ASP]
DATWYLER Training Certificate
DATWYLER Training Certificate
Anas Abu Tabaneh [APP, ASP]
BELDEN installer Certificate
BELDEN installer Certificate
Anas Abu Tabaneh [APP, ASP]
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀 (1)
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀 (1)
Anas Abu Tabaneh [APP, ASP]
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀
Anas Abu Tabaneh [APP, ASP]
Recommendation
Recommendation
Anas Abu Tabaneh [APP, ASP]
APPLE PRODUCT PROFESSIONAL 2015
APPLE PRODUCT PROFESSIONAL 2015
Anas Abu Tabaneh [APP, ASP]
APPLE PRODUCT PROFESSIONAL 2014
APPLE PRODUCT PROFESSIONAL 2014
Anas Abu Tabaneh [APP, ASP]
Network 101 rev1
Network 101 rev1
Anas Abu Tabaneh [APP, ASP]
Windows 10 Role Play for SMB
Windows 10 Role Play for SMB
Anas Abu Tabaneh [APP, ASP]
Microsoft Innovative Educator Experts
Microsoft Innovative Educator Experts
Anas Abu Tabaneh [APP, ASP]
Getting Started with Windows 10 for IT Professionals
Getting Started with Windows 10 for IT Professionals
Anas Abu Tabaneh [APP, ASP]
Anas Cv
Anas Cv
Anas Abu Tabaneh [APP, ASP]
Apple Product Professional 2016
Apple Product Professional 2016
Anas Abu Tabaneh [APP, ASP]
Windows Application Compatibility and Migration
Windows Application Compatibility and Migration
Anas Abu Tabaneh [APP, ASP]
Enhanced windows data encryption training
Enhanced windows data encryption training
Anas Abu Tabaneh [APP, ASP]
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀 (1)
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀 (1)
Anas Abu Tabaneh [APP, ASP]
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀
愆悋惆悸 悽惡惘悸 惓悸 愕惠-悋悴慍-悴悋惺悸 惡惠 愕愀
Anas Abu Tabaneh [APP, ASP]
Getting Started with Windows 10 for IT Professionals
Getting Started with Windows 10 for IT Professionals
Anas Abu Tabaneh [APP, ASP]
Windows Application Compatibility and Migration
Windows Application Compatibility and Migration
Anas Abu Tabaneh [APP, ASP]
Ad

Recently uploaded (20)

Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
resming1
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
Solar thermal Flat plate and concentrating collectors .pptx
Solar thermal Flat plate and concentrating collectors .pptx
jdaniabraham1
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
惠惘惘 惺 悋惠忰 悋惆悋 惠惆 悋悋悄 忰 悴悋忰.pdf
惠惘惘 惺 悋惠忰 悋惆悋 惠惆 悋悋悄 忰 悴悋忰.pdf
忰惆 惶惶 惠惠悸
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
Comparison of Flexible and Rigid Pavements in Bangladesh
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
20CE404-Soil Mechanics - 際際滷 Share PPT
20CE404-Soil Mechanics - 際際滷 Share PPT
saravananr808639
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
Fran巽ois Garillot
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
resming1
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
Solar thermal Flat plate and concentrating collectors .pptx
Solar thermal Flat plate and concentrating collectors .pptx
jdaniabraham1
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
FSE-Journal-First-Automated code editing with search-generate-modify.pdf
cl144
惠惘惘 惺 悋惠忰 悋惆悋 惠惆 悋悋悄 忰 悴悋忰.pdf
惠惘惘 惺 悋惠忰 悋惆悋 惠惆 悋悋悄 忰 悴悋忰.pdf
忰惆 惶惶 惠惠悸
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
Comparison of Flexible and Rigid Pavements in Bangladesh
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
20CE404-Soil Mechanics - 際際滷 Share PPT
20CE404-Soil Mechanics - 際際滷 Share PPT
saravananr808639
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
AI_Presentation (1). Artificial intelligence
AI_Presentation (1). Artificial intelligence
RoselynKaur8thD34
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
Fran巽ois Garillot
Ad

C++Chapter01.PPT

  • 1. Introduction to C++ Readings: 1.1-1.3, 1.9-1.13, 1.16-1.18, 1.21-1.22 C++ Bjarne Stroustrup (Bell Labs, 1979) started as extension to C (macros and variables) added new useful, features nowadays a language of its own C++ (the next thing after C, though wouldnt ++C be more appropriate?)
  • 2. Outline Intro to C++ Object-Oriented Programming Changes in C++ comments variable declaration location initialization pointer changes tagged structure type enum types bool type
  • 3. Object-Oriented Programming First-class objects - atomic types in C int, float, char have: values sets of operations that can be applied to them how represented irrelevant to how they are manipulated Other objects - structures in C cannot be printed do not have operations associated with them (at least, not directly)
  • 4. Object-Oriented Idea Make all objects, whether C-defined or user- defined, first-class objects For C++ structures (called classes) allow: functions to be associated with the class only allow certain functions to access the internals of the class allow the user to re-define existing functions (for example, input and output) to work on class
  • 5. Classes of Objects in C++ Classes similar to structures in C (in fact, you can can still use the struct definition) have fields corresponding to fields of a structure in C (similar to variables) have fields corresponding to functions in C (functions that can be applied to that structure) some fields are accessible by everyone, some not (data hiding) some fields shared by the entire class
  • 6. Instances of Classes in C++ A class in C++ is like a type in C Variables created of a particular class are instances of that class Variables have values for fields of the class Class example: Student has name, id, gpa, etc. fields that store values has functions, changeGPA, addCredits, that can be applied to instances of that class Instance examples: John Doe, Jane Doe each with their own values for the fields of the class
  • 7. Comments in C++ Can use C form of comments /* A Comment */ Can also use // form: when // encountered, remainder of line ignored works only on that line Examples: void main() { int I; // Variable used in loops char C; // No comment comment
  • 8. Variable Declarations In C++, variable declarations are not restricted to the beginnings of blocks (before any code) you may interleave declarations/statements as needed it is still good style to have declarations first Example void main() { int I = 5; printf(Please enter J: ); int J; // Not declared at the start scanf(%d,&J);
  • 9. Counter Variables in a For Loop You can declare the variable(s) used in a for loop in the initialization section of the for loop good when counter used in for loop only exists in for loop (variable is throw-away) Example for (int I = 0; I < 5; I++) printf(%dn,I); Variable exists only during for loop (goes away when loop ends)
  • 10. Initializing Global Variables Not restricted to using constant literal values in initializing global variables, can use any evaluable expression Example: int rows = 5; int cols = 6; int size = rows * cols; void main() { ...
  • 11. Initializing Array Elements When giving a list of initial array values in C++, you can use expressions that have to be evaluated Values calculated at run-time before initialization done Example: void main() { int n1, n2, n3; int *nptr[] = { &n1, &n2, &n3 };
  • 12. void* In C it is legal to cast other pointers to and from a void * In C++ this is an error, to cast you should use an explicit casting command Example: int N; int *P = &N; void *Q = P; // illegal in C++ void *R = (void *) P; // ok
  • 13. NULL in C++ C++ does not use the value NULL, instead NULL is always 0 in C++, so we simply use 0 Example: int *P = 0; // equivalent to // setting P to NULL Can check for a 0 pointer as if true/false: if (!P) // P is 0 (NULL) ... else // P is not 0 (non-NULL) ...
  • 14. Tags and struct When using struct command in C++ (and for other tagged types), can create type using tag format and not use tag in variable declaration: struct MyType { int A; float B; }; MyType V;
  • 15. enum in C++ Enumerated types not directly represented as integers in C++ certain operations that are legal in C do not work in C++ Example: void main() { enum Color { red, blue, green }; Color c = red; c = blue; c = 1; // Error in C++ ++c; // Error in C++
  • 16. bool C has no explicit type for true/false values C++ introduces type bool (later versions of C++) also adds two new bool literal constants true (1) and false (0) Other integral types (int, char, etc.) are implicitly converted to bool when appropriate non-zero values are converted to true zero values are converted to false
  • 17. bool operations Operators requiring bool value(s) and producing a bool value: && (And), || (Or), ! (Not) Relational operators (==, !=, <, >, <=, >=) produce bool values Some statements expect expressions that produce bool values: if (boolean_expression) while (boolean_expression) do while (boolean_expression) for ( ; boolean_expression; )