storm.cis.fordham.edu
.
address.C
.
The value of i is 10 The address of i is 0x7fff2757276c The number of bytes in i is 4
FF 00 00
FF 80 00
(a mixture of red and some green)
FF FF 00
(a mixture of red and lots of green)
00 FF 00
00 00 FF
41
.
42
.
43
.
61
.
|
(“bitwise or”): turn on a selected bit.
tolower.C
.
0101 | 0011 0111
int i {0x5}; //00000000000000000000000000000101 int j {0x3}; //00000000000000000000000000000011 int k {i | j}; //00000000000000000000000000000111
&
(“bitwise and”): turn off a selected bit.
toupper.C
,
binary.C
also uses right shift
>>
.
0101 & 0011 0001
int i {0x5}; //00000000000000000000000000000101 int j {0x3}; //00000000000000000000000000000011 int k {i & j}; //00000000000000000000000000000001
^
(“bitwise exclusive or”):
see if two bits are different.
logical.C
increments a three-bit integer;
see the simple machine on
page 11.
0101 ^ 0011 0110
int i {0x5}; //00000000000000000000000000000101 int j {0x3}; //00000000000000000000000000000011 int k {i ^ j}; //00000000000000000000000000000110
pointerint.C
,
pointerdouble.C
.
*
(star) operator
to dereference a pointer.
dereferenceint.C
,
dereferencedouble.C
.
[ ]
(subscript) operator
to dereference a pointer to an element in an array.
neighborint.C
,
neighbordouble.C
,
uniq.C
.
->
(arrow) operator
to dereference a pointer to a structure or a pointer to an object.
struct.C
,
obj.C
.
They invented the ->
because *
has lower
precedence
than .
(the dot operator).
pointeraddition.C
.
pointersubtraction.C
.
const
.
throw1.C
SIGABRT
.
Floating point exception (core dumped) echo $? 136
throw2.C
Attempted division by zero. echo $? 1
throw3.C
throw
.
throw4.C
An exception was thrown, carrying bad news: vector::_M_range_check: __n (which is 4) >= this->size() (which is 4) echo $? 1
new1.C
(looping with an int i
),
new2.C
(looping with a pointer q),
new3.C
(with
bad_alloc
).
vector<int>
.
vector.C
.
Insert capacity
to see the down side of this.
single1.C
.
list<int>
.
list.C
.
Simpler
example.
struct
, because
length
data member of class
date
See the two candidates in
jsr1
’s
height.h
,
height.C
,
main.C
.
.h
file) for a class
and its #
preprocessor directives,
implementation file (.C
file) for the class,
other files contain the rest of the program.
{
curly baces}
(for example, within the
{
curly baces}
of the main
function)
gets destructed when the computer reaches the closing curly brace.
This ensures that objects are destructed in
“last hired, first fired”
order:
the first object to be born will by default be the last to die,
like Methuselah in
announcer.h
,
announcer.C
,
main.C
.
If you want a different order,
each object should be placed in its own block of dynamically
allocated memory.