11-04-2012, 04:30 PM
C++
C++Chapter01.PPT (Size: 37 KB / Downloads: 175)
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 wouldn’t ++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)
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
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
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:
C++Chapter01.PPT (Size: 37 KB / Downloads: 175)
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 wouldn’t ++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)
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
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
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: