Digit Fastrack To C++ PDF
Digit Fastrack To C++ PDF
to
C++
By Team Digit
Credits
The People Behind This Book
EDITORIAL
Robert Sovereign-Smith Assistant Editor
Santanu Mukherjee, Supratim Bose, Nilay Agambagis, Bhaskar Sur Writers
DESIGN AND LAYOUT
Vijay Padaya, U Ravindranadhan Layout Design
Rohit Chandwaskar Cover Design
FAST TRACK
CONTENTS
Chapter 1
1.1
Basic Concepts
1.2
1.3
Inheritance
1.4
Polymorphism
1.5
Applications Of OOP
10
Chapter 2
11
2.1
Introduction To C++
11
2.2
Applications of C++
12
2.3
12
2.4
16
Chapter 3
Basics of C++
3.1
Program Structure
18
3.2
Variables
21
3.3
Data Types
27
3.4
Constants
28
3.5
Operators
32
3.6
Basic Input/output
38
Chapter 4
Control Structures
4.1
Branching
40
4.2
Looping
50
Chapter 5
Functions
61
5.1
Main Function
61
5.2
Function Prototyping
62
5.3
Call By Reference
66
5.4
Return By Reference
68
5.5
Inline Functions
68
5.6
Function Overloading
69
FAST TRACK
40
CONTENTS
Chapter 6
72
6.1
Specifying A Class
73
6.2
76
6.3
77
6.4
79
6.5
81
6.6
Friendly Functions
83
Chapter 7
87
7.1
Introduction
87
7.2
Constructors
88
7.3
Types of Constructors
91
7.4
97
7.5
Destructors
99
Chapter 8
8.1
Arrays
103
103
8.2
Character Sequences
108
8.3
Pointers
110
8.4
116
FAST TRACK
OBJECT ORIENTED
PROGRAMMING
C++
Object Oriented
Programming
OBJECT ORIENTED
PROGRAMMING
C++
Data
Binding
passing
Classes
Classes are used to implement the concept of Abstract Data
Types (ADT). A class is a combination of both properties and
methods used to manipulate properties. In fact, a class is a blueprint describing the nature of the data structure. For example,
consider the case of the class student. There are some common
properties shared by all students, such as name, roll, class,
address, and marks. Similarly, there might be some methods
used to manipulate these properties. However, the values of
these properties can differ depending in the student. If we want
to use the class student, then we need to create instances of
this class, also known as objects. Classes are user-defined data
types and behave like a built-in programming language.
Objects
Objects are the basic runtime entities in an object oriented system. In fact, it is the instance of a class. An object can be a person, place, bank account or even a table of data that the pro-
FAST TRACK
C++
OBJECT ORIENTED
PROGRAMMING
FAST TRACK
OBJECT ORIENTED
PROGRAMMING
C++
Inheritance
Polymorphism
1.3 Inheritance
This is another important feature of OOP. By Inheritance, classes can acquire the properties and methods of another class or
classes. Inheritance supports hierarchical classification. In
other words, the process by which the subclasses inherit the
attributes and behaviour of the parent class is termed as
Inheritance.
For instance, the class Dog may have sub-classes as Spitz,
10
FAST TRACK
OBJECT ORIENTED
PROGRAMMING
C++
1.4 Polymorphism
A Greek term, Polymorphism is the ability to represent oneself
in multiple forms. It helps the programmers to treat derived
class members, just like their parent class members. By implementing this concept, one can use an operator to perform different operations depending on the operands used.
For instance, if we consider two numbers, the operation
addition will generate a sum. Similarly, if the operands are
strings, then the operation will produce a third string by concatenation. This phenomenon of making an operator to exhibit
various behaviours in different instances is termed as operator
overloading.
It is also possible to use same name for different procedures
or methods, but the arguments or return types should be
unique for each one of them. Different codes are executed
accordingly depending on the arguments or the return type.
Let us assume there are three methods of a class sharing the
same name sum. One takes two integers as an argument and
returns an integer, the other takes three integers as an argument and returns an integer, while the third method takes two
floats as an argument and returns a float value. After creating
an object in the class, these functions will be called and the
FAST TRACK
11
OBJECT ORIENTED
PROGRAMMING
C++
method that matches the arguments and return type is executed. For example, if the method is called using two integers as an
argument and returns an integer value, then the first method is
executed. Similarly, the other two methods are executed as a
result of the corresponding argument and return type. This phenomenon is known as method overriding. The same name can
be used for methods in the parent and derived class.
OOP
Mapping
It
also helps in proper communication between objects by various message passing techniques, simplifying the interface
description.
12
FAST TRACK
C++
II
13
II
C++
Being
Maintenance
{
cout<< let us learn a wonderful language;
14
FAST TRACK
C++
II
return 0;
}
The output of the program is as follows:
let us learn a wonderful language
Now let us analyse the program and its statements in detail.
The first line, # include <iostream.h> is an integral part of the
program. #include is the directive used in the program and causes the pre-processor to add the contents of the input-output
stream file to the program. This directive also contains the declaration of the identifier cout and the operator <<.
// is a comment symbol. In C++, comments always starts with
a //. They always terminate at the end of the line. The comment
following a // is generally a single-line comment. int main() is
the most important line in the program. Every C++ program must
have a main() function, and the actual execution of any C++ program starts from this point. This function is called by the system
and returns a value to the system if required. In the above example, it will return a value of 0. If there is no value to return, then
int can be replaced by void. The parenthesis () is used to specify
an argument. In the absence of an argument, () can remain blank
or be replaced with void.
The next line, cout<<let us learn a wonderful language; prints the output on the screen. This line introduces two
new features, namely, cout and <<. cout is an identifier, a predefined object that resembles a standard output stream. << is known
as insertion operator that sends bytes to an output stream object.
return 0; is the function-return statement. This statement
returns a variable or value to the process called by the function. In
this case, it returns 0 to the system as mentioned above.
Additional C++ Statements
In C++ programming, statements play a major role. Statements are
FAST TRACK
15
II
C++
Expression Statements: These evaluate an expression for various side effects, or determine its return value.
Null Statements: These acts as a replacement for certain conditions when a statement is required by the C++ programming syntax, but not requiring any action.
Compound Statements: Widely used in the programming language, compound statements are basically groups of statements
enclosed in curly braces ({}). These statements can be conveniently used whenever we use a single expression.
Jump Statements: Mainly used for two purposes, either for trans-
ferring control to another location to execute a particular function, or returning control from a function.
16
FAST TRACK
C++
II
# include <iostream.h>
int main()
{
float x, y;
float sum, ave;
17
II
C++
store the result (sum/2), and determines the average of the two
numbers. The identifier cout and insertion operator << prints
the sum and the average of the two numbers.
#include <iostream.h>
class Rect {
int x, y;
public:
void setting_values (int,int);
int area () {return (x*y);}
};
18
FAST TRACK
C++
II
FAST TRACK
19
BASICS OF C++
C++
III
Basics Of C++
3.1 Program Structure
The following is a program that displays Hello World:
// This is the basic program in C++
#include <iostream.h>
int main ()
{
cout << Hello World!;
return 0;
}
Its output will be:
Hello World!
We see the text after compiling and executing the program.
Our compiler defines the compilation and editing process
involved in the program. Besides, they also depend on the version
and the interface (with variation in case of a Development
Interface) of the compiler. This example includes most of the components in a C++ program.
In order to understand it better, let us take a closer look at it.
//this is the basic program in C++
The program starts with a double slash, indicating a comment
and has no implication on the function or purpose of the program. You can add any comment to your program, but the only criterion is that it should be preceded with a double slash. These are
FAST TRACK
21
III
BASICS OF C++
C++
the short notes to the source code meant for programmers for
future reference.
#include <iostream.h>
The second line of our program starts with a hash (#) symbol.
Visibly, these are not typical lines with expressions. #include
<iostream.h> instructs the compilers pre-processor to hold the
iostream.h standard library file. In C++, the declarations of the
basic standard library of input and output are included in the
iostream.h standard file, which is used by the program in the
later sections of the program.
int main ()
This is the beginning of the main function of the program.
This point onwards, execution is independent of source code in
the case of C++. That is to say, all C++ programs must begin with a
main function. Also, we can see two parentheses after main.
This is a function declaration. These parentheses indicate the difference between a function declaration and the other expressions
in the source code. You can add a list of parameters within parentheses. The body of the main function follows the parentheses and
enclosed in braces ({}).
{
The next line in our program begins with a brace, indicating
the beginning of the body of the function. The statements mentioned in the body of the main function define the execution
process of the function. This opening brace is followed by our next
line of code.
cout << Hello World!;
22
FAST TRACK
BASICS OF C++
C++
III
#include <iostream.h>
int main ()
{
cout << Hello World! ;
cout << I am Learning Basic Structure of C++;
return 0;
}
The output of this program will be:
FAST TRACK
23
III
BASICS OF C++
C++
3.2 Variables
A variable is used to store a declared value that is used during the
execution of the program. As a programmer, you must declare a
variable before using it. The following is a general form of a declaration:
type variable_list;
Here, type is a valid data type or modifier. variable_list
usually includes a single name for an identifier. Multiple identifier names are separated by commas.
To understand it better, take a closer look at the following
lines:
int i,j,l;
short int si;
unsigned int ui;
double balance, profit, loss;
Now consider the following program,
// declaration of a variable
24
#include <iostream.h>
int main ()
{
FAST TRACK
BASICS OF C++
C++
III
// declaring variables:
int x, y;
int total;
// process:
x = 5;
y = 2;
x = x + 1;
total = x - y;
// print out the result:
cout << total;
// terminate the program:
return 0;
25
III
BASICS OF C++
#include<iostream.h>
int main()
{
int a;
a=10;
void show_a(void); //
show_a
show_a();
return 0;
}
void show_a(void)
{
cout<<a;
}
C++
prototype
of
function
26
BASICS OF C++
C++
III
Formal Parameter
We can insert Formal parameters in the function prototype as well
as in the function header of the definition. We also assign values
to the local variables using the argument while calling a function.
When a function involves arguments, it declares variables that
accept the values of the arguments passed while calling the function. These variables are called variables with formal parameters.
When they are inserted within a function then they behave as
local variables.
Example:
*/
27
III
BASICS OF C++
C++
This program uses the function is_in() that takes two arguments a and b. During the execution of the function, the values
for a and b are stored in the variables y and x, respectively.
Hence, the local variables y and x of the function is_in(),
accept the values of the argument while calling the function. The
function returns 2 if any character of y is similar to the value of
x, or else it returns 0. With the values used here, the function
will return 2 and is displayed as usual.
Global Variable
Global variables are created by declaring variables outside a function. Here, all expressions are independent of the blocks of code
they are inserted into. Any code can use global variables. These
variables can hold the values while executing the program. In the
following example, we can see that the variable calculate is
declared outside all functions of the program. A global variable is
best used when declared at the start of the program.
Example:
#include <iostream.h>
void cal1(void);
void cal2(void);
int main(void)
{
calculate = 100;
cal1();
return 0;
}
void cal1(void)
{
int temp;
temp = calculate;
cal2();
28
FAST TRACK
BASICS OF C++
C++
III
29
III
BASICS OF C++
C++
Description
Declares characters or small integers.
ASCII characters can be used with this
type of data.
short int (short) Declares short integers.
int
Declares integers and whole numbers in a
program. These numbers may be positive
or negative.
long int (long)
Declares longer numbers.
bool
Declares the Boolean value. Value can be
either true or false.
float
Declares floating point decimal numbers.
double
Declares double precision floating point
numbers.
long double
Declares long double precision floating
point numbers.
30
FAST TRACK
BASICS OF C++
C++
III
3.4 Constants
Constants always have a fixed value in a program. Similar to the
case of variables, constants also include various data types. They
are as follows:
Decimal
Octa
Notation
Notation
Hexadecimal
String
Back
Notation
Constant
Slash Constant
Meaning
Backspace
Form feed
New line
Carriage return
Horizontal tab
FAST TRACK
31
III
BASICS OF C++
\
\
\0
\\
\v
\a
\?
\N
\xN
C++
Double quote
Single quote
Null
Backslash
Vertical tab
Alert
Question mark
Octal constant (where N is an octal constant)
Hexadecimal constant (where N is a hexadecimal constant)
identifier value
us look at the example below:
NI 1.123456789
NEW \n
32
FAST TRACK
BASICS OF C++
C++
III
#define NEW \n
int main ()
{
double r=5.0;
is created for radius
double circle;
// This variable
circle = 2 * NI * r;
cout << circle;
cout << NEW;
return 0;
#include <iostream.h>
#include <limits.h>
int main()
{
cout << The minimum signed character: <<
SCHAR_MIN << \n;
cout << The maximum signed character: <<
SCHAR_MAX << \n;
FAST TRACK
33
III
BASICS OF C++
C++
-128
127
-32768
32767
SHRT_MAX
SHRT_MIN
USHRT_MAX
MB_LEN_MAX
In the cfloat library, we can get some double precision numbers provided by C++. These are as follows:
DBL_DIG
DBL_EPSILON
DBL_MANT_DIG
DBL_MAX
DBL_MAX_10_EXP
DBL_MAX_EXP
DBL_MIN
DBL_MIN_10_EXP
DBL_MIN_EXP
FLT_RADIX
FLT_DIG
FLT_EPSILON
FLT _MANT_DIG
FLT _MAX
FLT_MAX_10_EXP
FLT _MAX_EXP
FLT _MIN
FLT_MIN_10_EXP
FLT _MIN_EXP
LDBL_DIG
LDBL_EPSILON
LDBL_MANT_DIG
LDBL_MAX
LDBL_MAX_10_EXP
LDBL_MAX_EXP
LDBL_MIN
LDBL_MIN_10_EXP
LDBL_MIN_EXP
34
FAST TRACK
BASICS OF C++
C++
III
3.5 Operators
Operators help us to operate variables as well as constants.
Operators in C++ comprise various symbols. These are categorically divided into various groups.
Assignment Operator (=):
The Assignment Operator is used in any valid expression in C++.
Assume x is a variable and we want to assign a value 10 to it.
Here, we can use the following Assignment Operator:
x=10;
In this case, 10 is the integer value. The part on the left of the
Assignment Operator is the lvalue or left value and the right
part of the Assignment Operator is the rvalue or the right value.
Example:
// This is an example of assignment operator
#include <iostream.h>
int main ()
{
int x, y;
x = 10;
y = 4;
x = y;
y = 7;
// x:?,
y:?
// x:10,
// x:10,
// x:4,
// x:4,
y:?
y:4
y:4
y:7
FAST TRACK
35
III
BASICS OF C++
C++
Arithmetic Operators
+
*
/
%
Compound
assignment :
int main ()
{
int x, y=4;
x = y;
36
FAST TRACK
BASICS OF C++
C++
III
x+=3;
// this compound assignment
is equivalent to x=x+3
cout << x;
return 0;
}
The output of this program is as follows:
7
Increase
Operators
==
!=
>
<
>=
<=
Logical
operators:
There are three types of Logical Operators: !, && and II. We use
! in order to perform the NOT Boolean operation. && (AND) and
the II (OR) operators are used to evaluate two expressions in
order to get a single result.
&& returns TRUE if both expressions are separated. If either
of these expressions is false, then the operator returns FALSE.
FAST TRACK
37
III
BASICS OF C++
C++
operator
The symbol (?) is used as the Conditional operator. Look at the syntax of the Conditional Operator:
condition? result1: result2
This operator can evaluate an expression and return a value if
that is true. If the expression is incorrect i.e. If the condition
returns true then it yields a different value. In the above syntax, if
the condition returns true, result1 is executed, or else result2
is executed.
Example:
// This is an example of conditional operator
#include <iostream.h>
int main ()
{
int x,y,z;
x=2;
y=7;
z = (x>y) ? x : y;
cout << z;
38
FAST TRACK
return 0;
BASICS OF C++
C++
III
}
The output of the above program is as follows:
7
Three variables of integer type are declared in the first line of
the program above. Next, the value 2 is assigned to x and 7 is
assigned to y. Further, a conditional operator is used. If the value
of x is greater than that of y, then x is assigned to z, else y
is assigned to z. Here, the value of x is not greater than that of
y. Therefore, the value of y (7) is assigned to z. Finally, the
value of z is displayed on the screen as seen above.
Comma operator
The comma (,) is regarded as the Comma Operator and is used to
separate two expressions.
Example:
x = (y=3, y+2);
In the above line, x and y are two variables. Here, y=3 and
y+2 are separated by a Comma Operator.
Operators:
Symbols that are regarded as the Bitwise Operators are: &, |, ^,
~, <<, >>.
Bitwise
These are used to modify variables that can consider bit patterns and can represent the values stored by them.
Operator
&
|
^
~
<<
asm equivalent
AND
OR
XOR
NOT
SHL
39
III
BASICS OF C++
>>
SHR
C++
Shift Right
Example:
x = sizeof (char);
Precedence
of operators:
While writing a complex expression involving multiple operands,
we may encounter difficulties in deciding the sequence of
operands in the preferred order.
Let us look at the priority order from greatest to lowest:
Operator
Description
Grouping
() [] . -> ++ -- dynamic_cast
scope
Left-to-right
::
static_cast reinterpret_cast
const_cast typeid
* &
+ (type)
.* ->*
* / %
+ << >>
< > <= >=
== !=
&
^
|
&&
40
FAST TRACK
postfix
Left-to-right
unary (prefix)
Right-to-left
Right-to-left
type casting
Right-to-left
pointer-to-member
Left-to-right
multiplicative
Left-to-right
additive
Left-to-right
shift
Left-to-right
relational
Left-to-right
equality
Left-to-right
bitwise AND
Left-to-right
bitwise XOR
Left-to-right
bitwise OR
Left-to-right
logical AND
Left-to-right
BASICS OF C++
C++
||
logical OR
?:
conditional
= *= /= %= += -= >>= <<=
&= ^= |=
assignment
,
comma
III
Left-to-right
Right-to-left
Right-to-left
Left-to-right
FAST TRACK
41
III
BASICS OF C++
ed is: ;
<< i;
C++
cin >> i;
cout << You have inserted this value
42
FAST TRACK
CONTROL STRUCTURES
C++
IV
Control Structures
n previous chapters, we have seen that a program is a set of
statements separated by a semi colon. Also, these statements
are executed sequentially (one after another) from top to bottom. However, at times, the program needs to be executed either a
statement of a block at a time, depending on certain conditions.
This is known as control structure. There are two concepts
involved here - Branching and Looping.
4.1 Branching
The conditional execution of a statement or a group of statements
is known as Branching. For these purpose C++ provides the following two methods.
FAST TRACK
43
IV
CONTROL STRUCTURES
C++
44
FAST TRACK
CONTROL STRUCTURES
C++
IV
else
cout<<b is greater than a;
Here, when the value of a is greater than b (the condition is
true), it displays a is greater than b. If not, it displays b
is greater than a. In this case also, { } is required for multiple statements for both the if and else blocks.
The syntax is as follows:
if(condition)
{
statement 1;
statement 2;
---------------;
statement n;
}
else
{
statement 1;
statement 2;
---------------;
statement n;
}
45
IV
CONTROL STRUCTURES
C++
}
In the above example, when a is greater than b, then it executes the statements within { } after the keyword if. Otherwise,
it executes the statements within { } after the else keyword.
One can also use the if statement within another if statement or within an else statement. This is known as nested if
concept. For example, if we want to find out the greatest out of
three numbers stored in three variables, the code will be as follows:
if(a>b)
{
if(a>c)
{
cout<<the
cout<<a;
}
else
{
cout<<the
cout<<c;
}
}
else
{
if(b>c)
{
cout<<the
cout<<b;
}
else
{
cout<<the
cout<<c;
}
}
46
FAST TRACK
C++
CONTROL STRUCTURES
IV
47
IV
CONTROL STRUCTURES
C++
a leap year;
else
cout<<You have entered <<year<< and this is
not a leap year;
}
else
{
if(year%4==0)
cout<<You have entered <<year<< and this is
a leap year;
else
cout<<You have entered <<year<< and this is
not a leap year;
}
}
The output of this program is as follows:
Please enter any year of your choice => 1998
You have entered 1998 and this is not a leap year
Before we proceed with the explanation of the program, we
need to know the criterion that decides a leap year. If a year is
divisible by 400, then it is a leap year.
In the above program, the year i.e. the integer value is accepted and stored in an integer variable. The if statement checks
whether the value is divisible by 100. If the condition returns
true, then the second if statement checks whether the value is
divisible by 400. If this condition is also true, then the given
value i.e. the year will be a leap year and a message is displayed
with the value entered by the user. If the second if statement
returns false, then the year will not be a leap year and a corresponding message is displayed along with the value of the year
to show the result. Now if the first if statement returns false,
i.e. if the value is not divisible by 100, then the control moves to
the else part that checks whether the value is divisible by 400
or not by the second if statement. If this holds true, then the
48
FAST TRACK
CONTROL STRUCTURES
C++
IV
default:
statement 1;
statement 2;
--------------- ;
FAST TRACK
49
IV
CONTROL STRUCTURES
C++
statement n;
}
Here, n is a positive integer. Any case from 1 to n is executed depending on the expressions value. If there is no such value
of expression that satisfies any case, then default statement(s) are
executed. There is a slight difference in constructing blocks in an
if and switch statement. In a switch statement, a label
break is used to terminate a particular case instead of { } in the
case of an if statement. Let us go through the following program
carefully.
# include<iostream.h>
int main()
{
int a;
cout<<Enter your Choice=>;
cin>>a;
switch(a)
{
case 1:
cout<<You are in block 1;
cout<<\nyour choice is <<a;
50
case 2:
cout<< You are in block 2;
cout<<\nyour choice is <<a;
break;
case 3:
cout<< You are in block 3;
cout<<\nyour choice is <<a;
break;
default:
cout<<You are in block default;
cout<<\nyour choice is <<a;
}
FAST TRACK
CONTROL STRUCTURES
C++
IV
Grade
FAST TRACK
51
IV
CONTROL STRUCTURES
=100
>=80
>=60
>=40
>=20
>20
C++
A
B
C
D
E
F
52
FAST TRACK
CONTROL STRUCTURES
C++
IV
case 1:
cout<<You have obtained <<a<< marks;
cout<<\nYour grade is E;
break;
default:
cout<<You have obtained <<a<< marks;
cout<<\nyour grade is F;
}
4.2 Looping
There are instances where we need to execute a block of statements in a loop as long as a condition holds true. There are two
types of loops exit control loop and entry control loop. In an exit
control, the loop condition is checked after execution of the statement(s) while in the looping block. When the condition returns
true, the control enters the loop once again. The do-while statement falls under this category. Similarly, in an entry control loop,
FAST TRACK
53
IV
CONTROL STRUCTURES
C++
54
CONTROL STRUCTURES
C++
IV
}
In this program, there are 3 variables - roll, name and
marks are created to accept the values of roll no, name and
marks of a student, respectively. Also, another variable ch is created to accept the users choice whether he wants to enter another record or not. Initially, the variable ch is not given any value.
The do-while loop enters into the body of the loop without checking for any condition. The reason it is an exit control loop. Next,
it accepts the roll no, name and address from the user and also displays the entered information as follows:
Your name is=><the name entered by user>
Your roll no. is=><the roll no entered by user>
Your marks is=><the marks entered by user>
Another line is displayed on the screen to ask the user for
another record. Next, the response from the user is checked by the
while statement. If the condition holds true, then the body of
the loop is executed, or else the execution stops. The message displayed is:
Want to enter another record=>
If the user enters y, then the condition holds true, and the
body of the loop is executed once more. That is, it again accepts and
displays the values of roll no., name and marks. This process continues until the user enters any character other than y (say n).
55
IV
CONTROL STRUCTURES
statement 2;
-------------statement n;
C++
}
In this kind of loop, first the condition is checked. If the condition holds true, then the body of the loop is executed. After execution, the condition is checked and executes depending on the
return value of the condition. This process continues till the condition returns false.
Program 4
Now if we want to display the first 10 integers on screen, the program will be as follows
#include<iostream.h>
int main()
{
int x=1;
while(x<=10)
{
cout<<\t<<x;
x++;
}
}
The output of the above program will be
1 2 3 4 5 6 7 8 9 10
Initially, an integer variable x is created and initialized by 1.
Next, the condition checks whether the value of x is less than or
equal to 10. The condition obviously holds true and the body of
the loop is executed. 1 is displayed on the screen and also the
value of x is incremented by 1. Again the condition is checked
and the body of the loop is executed. This process continues till
the value of x is greater than 10, i.e. 11. When the value of x is
11, then the condition will return false, and the body of the loop
is not executed further.
56
FAST TRACK
CONTROL STRUCTURES
C++
IV
FAST TRACK
57
IV
CONTROL STRUCTURES
C++
Program 5
#include<iostream.h>
int main()
{
int x=1;
while(x<=10)
{
if(x==7)
{
cout<<\n\tWe skipped a number\n;
x=x+1;
continue;
}
cout<<\t<<x;
x=x+1;
}
}
Output of the above program is
1 2 3 4 5 6
We skipped a number
8 9 10
Initially, the execution will be the same as the earlier program.
Numbers from 1 to 6 will be displayed. After that, the value of x
will be 7. This is less than 10. Therefore, the control enters into a
loop. However, the if statement holds true and enters the if
block. Here, the message We skipped a number is displayed.
Next, the value of x is increased by 1 and reaches the continue
statement. Therefore, the remaining statements in the loop are
not executed, and the condition for the while statement is
checked. Since the value of x is now 8, the body of the loop is executed, thereby displaying the numbers from 8 to 10. The number
7 is not displayed because of the continue statement.
58
FAST TRACK
CONTROL STRUCTURES
C++
IV
59
IV
CONTROL STRUCTURES
C++
Program 7
The following program accepts a number from the user. If the user
enters an even number, it stops execution.
#include<iostream.h>
int main()
{
int x;
char check=y;
while(check==y)
{
cout<<Execution will stop if you enter even
number;
cout<<\nEnter a number=>;
cin>>x;
if(x%2==0)
{
cout<<\nyou have entered an even number;
check=n;
}
}
}
Here, the program first creates an integer variable x and a
character variable check. The character variable is then initialized by y. If the condition of while holds true, the control
enters the loop. Here, it prompts the user to enter a number. If the
user enters an odd number, then the if condition holds false.
The value of check will remain y. Therefore, the condition of
the loop holds true and the body of the loop is executed again.
This process continues till the user enters an even number. If the
user enters an even number, the if condition holds true and its
body is executed which prints a message. The value of check
becomes n. Finally, the condition of the loop is checked, and the
execution of the program ends once the condition is false.
60
FAST TRACK
CONTROL STRUCTURES
C++
IV
FAST TRACK
61
IV
CONTROL STRUCTURES
C++
Program 8
#include<iostream.h>
int main()
{
int x;
for(x=1;x<=10;x++)
cout<<x<<\t;
}
The output of the above program will be:
1 2
10
62
#include<iostream.h>
int main()
{
int x,y,fact;
cout<<Enter a number=>;
cin>>x;
fact=1;
for(y=1;y<=x;y++)
{
fact=fact*y;
}
cout<<\nFactorial of <<x<< is <<fact;
}
FAST TRACK
CONTROL STRUCTURES
C++
IV
FAST TRACK
63
FUNCTIONS
C++
Functions
5.1 Main Function
Functions are vital in programming development. For the sake of
convenience and simplicity, a program is divided into smaller
units called functions. This is one of the major principles of
sequential structural programming. However, the advantage of
using functions in a program is to reduce the size of the program.
The functions are called at different phases of the program to simplify its execution.
The main() function generally returns a value of type int. The
language defines the main() method and matches one of the following prototypes. These are as follows:
int main();
int main(int argc, char * argv[]);
It is to be noted that functions returning a value should always
use the return statement. Hence, whenever we declare and define
a function, it should be declared as follows:
int main()
{
statements
.statements
return 0;
}
By default, the return functions is of type int and is considered optional in the main() header of a program. For any function
that has a return value, there should be a return statement withFAST TRACK
65
FUNCTIONS
C++
66
FAST TRACK
FUNCTIONS
C++
Here, type is the data type specifier that specifies the type of
data returned by the function. name is the identifier that mainly
calls the function. The third and the most important factor is the
parameter. Each parameter passed, consists of a data type specifier followed by an identifier. The parameter also allows arguments
to pass to that particular function when it is called at a certain
phase in the program. Parameters passed must always be separated by commas.
Consider two programs where this concept is implemented.
Program1
// function example
67
FUNCTIONS
C++
int m;
m = add(10,9); // the function add is called in
the main method
cout << "The result is " <<m;
return 0;
}
Output:
The result is 19
Here, in the main function of the above program, first a variable called m is declared of the type int. The next line of the
program calls a function named add which is defined above.
The result of this function is stored in the variable m. Two values
10 and 9 are passed as values within the function that correspond to the int x and int y parameters declared for function addition. The value of both the arguments that are passed
in the function are subsequently copied to the local variables x
and y. Now note in the function declaration, a function called
add is declared with two parameters x and of the type int.
Another variable called z is then declared of the type int which
stores the result of the addition.
return (z); is one of the main statements of the program.
This statement returns the control to that part of the program
that called the function and also returns the value passed by it. In
this case, since the function add is called by the variable m in the
main function, it will return the control to the statement m =
add(10,9); and value of z will be assigned to m. The value of m is
then displayed.
Program2
#include <iostream.h>
int sub(int m, int n)
{
int k;
k=m-n;
return (k);
}
68
FAST TRACK
FUNCTIONS
C++
int main ()
{
int x=5, y=3, v;
v = sub(7,2);
cout << "The first result is " << v << '\n';
cout << "The second result is " << sub(7,2) <<
'\n';
cout << "The third result is " << sub(x,y) <<
'\n';
v= 4 + sub(x,y);
cout << "The fourth result is " <<v << '\n';
return 0;
}
The output of this program is:
The
The
The
The
first result is 5
second result is 5
third result is 2
fourth result is 6
69
FUNCTIONS
C++
and y and the value returned by the function sub will be 2 in this
case is displayed. In the next line the function sub is again called
by the variables x and y. This time the return value is stored in the
variable v after adding 4 to it. So the value of v will be 6 and is displayed by the next line.
#include <iostream.h>
void duplet(int& m, int& n, int& o)
{
m*=2;
n*=2;
o*=2;
}
int main ()
{
int x=2, y=7, z=9;
70
FAST TRACK
FUNCTIONS
C++
71
FUNCTIONS
C++
x, int& y)
if (x<y)
return x;
else
return y;
}
72
FAST TRACK
FUNCTIONS
C++
Here, type is the data type of the inline function, while name
refers to the name of that particular inline function.
For example consider the following:
inline float
{
area(float a, float b)
return(a*b);
}
73
FUNCTIONS
C++
return 0;
74
FAST TRACK
FUNCTIONS
C++
declared above
FAST TRACK
75
C++
VI
77
VI
C++
nated with a semicolon after the closing curly brace (}). Objects
can also be created within the main() function. The syntax is
as follows:
Class_name object_name;
Here, class refers to the class whose object is to be created.
object_name represents the name of the object.
78
FAST TRACK
C++
};
VI
public:
void set_values (int,int);
int area () {return (x*y);}
int main () {
Calculation r1, r2;
r1.set_values (6,7);
r2.set_values (8,8);
cout << r1 area: << r1.area() << endl;
cout << r2.area: << r2.area() << endl;
return 0;
}
The output of this program is:
r1 area: 42
r2.area: 64
#include <iostream.h>
class C1{
int x, y;
FAST TRACK
79
VI
C++
public:
void s1(int,int);
int area () {return (x*y);}
};
void C1::s1(int a, int b) {
x = a;
y = b;
}
int main () {
C1 r5;
r5.s1(6,5);
cout << area: << r5.area();
return 0;
}
The output of this program is:
area: 30
80
FAST TRACK
C++
VI
void
void
number = k;
cost = n;
}
81
VI
C++
public:
void get_value(int x, float y);
void put_value (void)
{
cout<< number : <<number<<\n;
cout <<cost: << cost <<\n;
}
};
i2.get_value(378,78.6);
i2.put_value();
i1 i3;
cout <<\n object i3 <<\n;
i3.get_value(37,8.6);
82
FAST TRACK
C++
VI
i3.put_value();
return 0;
}
FAST TRACK
83
VI
C++
int s1 :: l1(void)
{
if(m>= o)
return(m);
else
return(o);
}
void s1 :: i1(void)
{
cout<<input values of m and o<<\n;
cin>>m>>o;
}
void s1 :: d1(void)
{
cout << largest value= <<l1()<<\n;
member function l1() is called
}
84
FAST TRACK
// the
C++
VI
int main()
{
s1 s2;
s2.i1();
s2.d1();
return 0;
}
The output of this program is:
Input values of m and o
67 78
[These values are entered by the user from keyboard during
execution of the program]
largest value=78
FAST TRACK
85
VI
C++
int x;
static int y; // This is a static member variable
public:
void set(void)
{
x= ++y;
}
void show(void)
{
cout<< object number: <<x <<\n;
}
86
FAST TRACK
C++
VI
t1 :: y;
int main()
{
t1 m1,m2;
m1.set();
m2.set();
t1 :: s1();
t1 m3;
m3.set();
m1.show();
m2.show();
m3.show();
return 0;
2
number: 1
number: 2
number: 3
87
VI
C++
tains the count of the number of objects that is created. The show()
function displays the code number for each object. Consider the
statement x = ++y;
This statement is executed whenever the set() function is called
and the current value of the variable y is assigned to the code.
88
FAST TRACK
C++
VI
int main()
{
s1 k;
k.set();
cout<< Mean value = <<m1(k) <<\n;
return 0;
}
The output of this program is:
Mean value = 45
89
VI
C++
int x;
public:
void set(int i) {x=i;}
friend void m1(MN2,MN1);
};
class MN1
{
int a;
public:
void set(int i) {a=i;}
friend void m1(MN2,MN1);
};
void m1(MN2 m, MN1 n) // The friend function m1
is defined
{
if(m.x >= n.a)
cout << m.x;
else
cout <<n.a;
}
int main()
{
MN1 mn1;
mn1.set(15);
MN2 mn2;
90
FAST TRACK
C++
VI
mn2.set(25);
m1(mn2,mn1);
return 0;
}
The output of this program is:
25
Here, the function m1() has arguments from both the classes
MN2 and MN1. When the function m1 is declared as a friend function in the class MN2 for the first time, the compiler does not
acknowledge the presence of the class MN1, unless we declare its
name at the beginning of the program as class MN1; This is
known as the forward declaration.
FAST TRACK
91
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
Constructors And
Destructors
7.1 Introduction
Member variables can be initialised while creating the objects by
using constructors. We can also destroy the objects when they are
not required using destructors.
Classes have a very complicated structure. We can use constructors and destructors to initialise member variables of a class
or destroy class objects. Besides, initialisations for objects construction also indicate memory allocation for the objects.
Similarly, besides cleaning up objects, destructors de-allocation of
memory used by the objects.
Constructors and destructors are usually declared within the
declaration of a class. Here, you can define them either inline or
external to the class declaration. Default arguments can be included in the constructors. Constructors and destructors also have
some limitations.
Features of return values and return types are not found in
constructors and destructors. Destructors don't take any argument. Programmers cannot use references and pointers in constructors. The keyword virtual cannot be used while declaring a
constructor. Class objects that include constructors and destructors cannot be inserted in the unions. Constructors and destructors always maintain the access rules of member functions. The
compiler where the whole program is run can automatically call
constructors while defining class objects. Similarly, the compiler
can automatically call destructors where the class objects turn to
be insignificant.
FAST TRACK
93
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
7.2 Constructors
The task of a constructor is to set up the object in order to make it
usable. These are special members of functions in a class. It can
only build an object that belongs to its class. Constructors maintain the same name as that of a class. You can insert any number
of overloaded constructors in a class. However, there should be a
different set of parameters.
Constructors do not return any values. These are not created
between base and the derived classes. If we do not provide a
Constructor then the compiler creates a default constructor that
does not include any parameter. This is so as there must be a constructor and it can be empty or a default constructor. No default
constructor will be created if a constructor with parameter is supplied by the programmer. Constructors cannot be virtual. You can
define the multiple constructors for the same class.
Here is an example of a constructor.
Syntax:
class dealer
{
private:
int person_identity ;
float daily_sales ;
public:
dealer() //default constructor
{
person_identity = 0 ;
daily_sales = 0.00 ;
}
};
Now let us look at the following example:
//here we can get class with a constructor
class integer
94
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
Int x, y;
Public:
Integer(void) ;
the constructor is declared
} ;
integer
:: integer(void)
the constructor is defined
{
x = 0; y = 0;
}
//here
//here
Here, we can see that a class includes a constructor, and is initialised automatically when an object is created. Look at the declaration below:
Integer int2;
ated
Exception before the completion of a constructor causes difficulties. In such a case, a destructor for cleaning the object will not
appear. Here, the most common problem is the allocation of
resources in constructors. The destructor will not get scope for the
de-allocation of resources if any exception appears in the constructor. This problem often happens in case of 'naked' pointers.
Let us go through the following example:
Example:
//: problems if exception is thrown in the constructor before completion
// Naked pointers
FAST TRACK
95
VII
CONSTRUCTORS AND
DESTRUCTORS
#include <fstream.h>
ofstream out("nudep.out");
class Rat {
public:
Rat() { cout << "Rat()" << endl; }
~Rat() { cout << "~Rat()" << endl; }
};
class Frog {
public:
void* operator new(size_t sz) {
cout << "allocating a Frog" << endl;
throw int(47);
}
void operator delete(void* p) {
cout << "deallocating a Frog" << endl;
::delete p;
}
};
class UseResources {
Rat* bp;
Frog* op;
public:
UseResources(int count = 1) {
cout << "UseResources()" << endl;
bp = new Rat[count];
op = new Frog;
}
~UseResources() {
cout << "~UseResources()" << endl;
delete []bp; // Array delete
delete op;
}
};
int main() {
try {
UseResources ur(3);
96
FAST TRACK
C++
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
} catch(int) {
cout << "inside handler" << endl;
}
} ///:~
The output of this program is:
UseResources()
Rat()
Rat()
Rat()
allocating a Frog
inside handler
97
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
98
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
Square q1 ;
//here the first Constructor without any argument
is invoked
;
'\n" ;
arguments is invoked
q2.View_area() ;
}
First Square---------'
Second Square-------'
The area of the Square = 19.6
Another type of constructor is a copy constructor. Let us
look at the form of the copy constructor:
class name (class name &).
While initialising an instance, the copy constructor is used
by the compiler. Here, the values of the other instance of the
same type are used.
FAST TRACK
99
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
100
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
char *z1;
int l1;
public:
S1()
//this is the constructor-1
{
l1 = 0;
z1 = new char[l1 +1];
}
S1(char *x)
//constructor-2
{
l1 = strlen(x);
z1 = new char[l1 +1];
//one additional
FAST TRACK
101
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
//character
for \0
strcpy(z1, x);
}
void display(void)
{cout <<z1 << "\n";}
void include(S1 &m, S1 &n);
};
void S1 :: include(S1 &m, S1 &n)
{
l1 = m.l1 +n.l1;
delete z1;
z1 = new char[l1+1];
//dynamic
allocation
};
int
{
strcpy(z1, m.z1);
strcat(z1, n.z1);
main()
naming2("Ram
t1.include(naming1,naming2);
t2.include(t1, naming3);
naming1.display();
naming2.display();
naming3.display();
t1.display();
t2.display();
return 0;
102
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
Jack
Ram
Raj
Jack Ram
Jack Ram Raj
103
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
z2=u;
q= new int *[z1];
//Here
the
an array pointer is created
for (a = 0;a<z1;a++)
q[a] = new int[z2]; //Here space
for each row is created
}
int main()
{
int l, p;
matrix: ";
cin>>l>>p;
matrix A(l,p);
object A constructed
//matrix
cout<<"Here you can enter the matrix elements row by row \n";
int a,b,cost;
for(a=0;a<l;a++)
{
for(b=0;b<p;b++)
{
cin>>cost;
A.getting_element(a,b,cost);
}
}
cout<<"\n";
cout<<A.insert_element(2,3);
return 0;
104
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
22
66
111
33
77
222
44
88
333
7.5 Destructors
Destructors are not as complicated, and are called automatically.
There is only one destructor per object. A destructor has a single
name, its class and is headed by a tilde (~) operator.
Let us look at the example below:
performer::~performer() {
potency = 0;
nimbleness = 0;
fitness = 0;
}
Consider the following example of both constructor and
destructor:
Example:
//example
destructor
including
both
constructor
and
#include <iostream.h>
class Plant {
FAST TRACK
105
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
int tallness;
public:
Plant(int initialTallness); // a Constructor is
inserted here
~Plant(); // a Destructor appears with a tilde
sign
void growth(int years);
void copysize();
};
Plant::Plant(int initialTallness) {
tallness = initialTallness;
}
Plant::~Plant() {
cout << "inside Plant destructor" << endl;
copysize();
}
void Plant::growth(int years) {
tallness += years;
}
void Plant::copysize() {
cout << "Plant tallness is " << tallness << endl;
}
int main() {
cout << "before opening brace" << endl;
{
Plant t(12);
cout << "after Plant creation" << endl;
t.copysize();
t.growth(4);
cout << "before closing brace" << endl;
}
cout << "after closing brace" << endl;
} ///:~
The output of this program is:
before opening brace
106
FAST TRACK
CONSTRUCTORS AND
DESTRUCTORS
C++
VII
107
VII
CONSTRUCTORS AND
DESTRUCTORS
C++
108
FAST TRACK
C++
VIII
Compound Data
Types
8.1 Arrays
rrays are defined as a series of elements of the same type,
placed in contiguous memory locations. They are referenced individually, by adding an index to a unique identifier. An array can also be defined as a data structure, allowing
a collective name to be given to a group of elements having the
same type. The individual element of an array is identified by its
own unique index. This is also referred as the subscript of the
element.
If we want to store six values of the type integer, but don't want
to declare a variable with a different identifier for each of them,
we can do it by using arrays.
This is shown as follows:
Jim
]
Integer
Here, the array Jim is of type integer that contains six integer values and is represented as shown above. Each blank panel
shown above represents an individual element of the array Jim.
The elements of the array are numbered from 0 to 5. These numbers are called index of the array element. Note that in arrays, the
first index is always 0. An array is like a regular variable and
should be declared before it can be used. A normal array declaration is as follows:
FAST TRACK
109
VIII
C++
110
FAST TRACK
C++
VIII
Jim[2] = 60;
If we want to pass the value of the third element of the array
to a variable x, we can write:
x = Jim[2];
111
VIII
C++
}
cout << res;
return 0;
Jim
0
1
2
Multidimensional arrays
A multidimensional array is an "array of arrays". This can be represented as follows:
In the above example, Jim represents a bi-dimensional array of
3 x 4 elements of type integer. This is declared as:
int Jim[3][4];
In C++, in order to accept arrays as parameters while declaring
a function, it is required to specify the element type of the array
in its parameters - an identifier and a pair of void brackets [].
Consider the following statement:
void p1(int
a1[])
112
FAST TRACK
C++
VIII
// arrays as parameters
#include <iostream.h>
FAST TRACK
113
VIII
C++
m1[] = {'I','n','d','i','a','\0'};
114
FAST TRACK
C++
VIII
while the last null character is for specifying the end of the
sequence. In the second case, by using string literals, the null
character ('\0') is automatically inserted at the end.
Applying Null-terminated Sequence Of Characters
Null terminated sequence of characters is an effective way of
treating strings. They can also be used in procedures. For example, the extraction and insertion operators cin and cout support these sequences and can be used directly to extract strings
of characters or to insert them. The following program illustrates this.
";
115
VIII
C++
entered is assigned to the array y1. Now if the number of characters entered is less than the number of elements specified during
declaration of y1, then \0 will append just after the last entered
character. If some one enters Harry as shown above, y1 will be as
follows
y1
/0
8.3 Pointers
Identifiers also help us to refer to our variables. When a variable is
declared, it is assigned a specific memory address.
Reference variable
Each variable has a specified address in the memory known as
the reference to that variable. With the help of this
address, a certain variable can be located within the memory. A
reference to this variable is obtained by putting the & symbol
before the identifier. For example, Jim=&Jack; assigns the
address of the variable Jack to the variable Jim. Here, & is the reference operator that precedes the variable Jack. Consider the following code segment:
a1 = 52;
f1 = a1;
t1 = &a1;
116
FAST TRACK
C++
VIII
variable t1. This is due to the presence of the address of operator &
that precedes the identifier a1. Thus a pointer may be defined as
a variable that stores the reference to another variable.
Pointers are special variables that store the reference of a
variable of its type. That means an integer pointer can store the
address of an integer variable, a float pointer can store the address
of a float variable and so on. In the above examples, all variables
used to store reference of other variables are pointers. Pointers
play a vital role and have uses in various applications. Generally a
pointer is defined as follows:
type * name;
Here, type refers to the data type of the variable that the
pointer points to. Let us take another example that is shown
below.
int * n1;
char * c1;
float * g1;
Here, three pointers have been declared. Each pointer that is
declared points to a different data type, but all of them occupy
the same amount of space in the memory. However, the data to
which the pointers point to, are of different types - the first
pointer points to an int, the second points to a char and last
one points to a float. Now let us look at a program which is
based on pointers.
// Program 1
// Application of pointers
#include <iostream.h>
int main ()
{
int f1, s1;
int * m1;
FAST TRACK
117
VIII
C++
m1 = &f1;
*m1 = 56;
m1 = &s1;
*m1 = 78;
cout << "first value is " << f1 << endl;
cout << "second value is " << s1<< endl;
return 0;
118
FAST TRACK
C++
f1
s1
60
VIII
p3 = &f1;
// p3 = address of
*p3 = 60;
// value pointed by p3 =
p4 = &s1;
// p4 = address of
*p4 = *p1;
// value pointed by p4 =
value pointed by p3
p3 = p4;
// p3 = p4 (value of
pointer is copied)
*p3 = 20;
// value pointed by p3
= 20
cout << "first value is " << f1 << endl;
cout << "second value is " << s1 << endl;
return 0;
}
The output of this program is:
first value is 60
second value is 20
Initially, two variables, f1 and s1 of the type int are declared.
Then, two pointers p3 and p4 are declared. These are also of type
int. Initial values are assigned to the variables f1 and s1. Next, a
reference to the variables f1 and s1 is assigned to the pointers p3
and p4. The next statement *p3=60 assigns the value 60 to the
memory location pointed by the pointer p3.
Pointers and arrays
Arrays are similar to pointers. Consider the two declarations
below:
int n1[15];
// n1 is an array of type
int
int * x;
// x is a pointer of type
int
FAST TRACK
119
VIII
C++
120
FAST TRACK
C++
VIII
return 0;
Here, the first expression p1 = new type is used for allocating memory so that one single element of type type can be contained. Similarly, the second expression is used for assigning an
array of elements of type type. Here, number_of_elements is an
integer value. Consider the statements:
int * b;
b = new int [6];
FAST TRACK
121
VIII
C++
122
FAST TRACK
C++
x
y
p1
f1
VIII
member_type1 member_name1;
member_type2 member_name2;
member_type3 member_name3;
.
.
} object_names;
123
VIII
C++
124
FAST TRACK
C++
VIII
Enumerations enum
An enumeration is a data type that can be given a finite set of
named values, each of which has a meaningful name. It can be
declared as follows:
enum enumeration_name {
value1,
value2,
value3,
.
.
} object_names;
For instance, consider the following declaration. Here, a new
type called t1 is created for storing different values.
enum t1 {tx, ty, tz, tn, th, tu, ti, td};
Note that no fundamental type has been included in the declaration part. In fact, a completely new data type has been created.
The values that are present within the braces are the new constant
values.
After the enumeration t1 has been declared, we can declare
the following expressions based on it. They are as follows:
t1 tq;
tq = tj;
The constants of the enumeration are assigned an integer
numerical value internally. It is to be noted that the first enumerator has a value 0 and each successive enumerator is one greater
FAST TRACK
125
VIII
C++
126
FAST TRACK
C++
VIII
Notes
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
......................................................................................................................
FAST TRACK
127
VIII
C++
Notes
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
....................................................................................................................................
128
FAST TRACK