Programming and Graphics

(Kiana) #1

108 Introduction to C++ Programming and Graphics


12 2048 4095
13 4096 8191
14 8192 16383
15 16384 32767
16 32768 65535
17 65536 131071
18 131072 262143
19 262144 524287
20 524288 1048575
21 1048576 2097151
22 2097152 4194303
23 4194304 8388607
24 8388608 16777215
25 16777216 33554431
26 33554432 67108863
27 67108864 134217727
28 134217728 268435455
29 268435456 536870911
30 536870912 1073741823
31 1073741824 2147483647

Please enter the number of bits
(should be less than 32)
q to quit
------------------------------
q

Returnofanalias


An alias, also called a reference, is a duplicate name of a defined variable.
In Chapter 2, we saw that an alias can be declared by stating, for example,


double a;
double&b=a;

In this case,bis an alias ofa.


A function can receive a number of variables, and return an alias to one
of these variables. For example, the following function receives two integers and
returns a reference to the greater


int& maxalias(int& a, int& b)
{
if(b>a)
{
return b;
}
Free download pdf