Programming and Graphics
5.1 Pointers to scalars and characters 129 or double *pname Similar declarations are made for other types. Once declared, a poin ...
130 Introduction to C++ Programming and Graphics The prefix & in the statements evaluating the pointer variables is the refe ...
5.1 Pointers to scalars and characters 131 Two ways of changing a variable We can change the value of variable either directly o ...
132 Introduction to C++ Programming and Graphics #include <iostream> using namespace std; int main() { float A[2][2]={{1.1 ...
5.1 Pointers to scalars and characters 133 { double a=8.45; double * memada; double ** memadb; memada = &a; memadb = &me ...
134 Introduction to C++ Programming and Graphics It would seem that this method can be used to extract the content of a given me ...
5.2 Pointers to vectors and strings 135 Note that it isnotpermissible to state: double * memad1 = &A; A vector name is a poi ...
136 Introduction to C++ Programming and Graphics cout << memad1 <<""<<memad2 << " "<< memad3 <& ...
5.3 Sorting with the STL 137 char oros[l]; char * memad; for (int i=0;i<l;i++) { memad = &onoma[i]; oros[i] = *memad; cou ...
138 Introduction to C++ Programming and Graphics These two statements can be replaced by the single statement: sort(v, v+N) whic ...
5.3 Sorting with the STL 139 Order of an algorithm We can assess the performance of thesortfunction by studying the relation bet ...
140 Introduction to C++ Programming and Graphics Problems 5.3.1.Use thesortfunction to alphabetize a list of ten African countri ...
5.4 Command line arguments 141 we will see on the screen: 1os 2is 3 running We can use a double pointer to simplify the argument ...
142 Introduction to C++ Programming and Graphics Print a file In a more advanced application, we generate a binary executable na ...
5.5 Pointers to functions 143 Assume that we need to call a function A which, in turn, calls either function B or function C. We ...
144 Introduction to C++ Programming and Graphics int menu; double a = 4.0; double b = 2.0; double result; cout << "Please ...
5.6 Pointers to free memory 145 The syntax of the function-pointer declaration is illustrated near the top of the code. The main ...
146 Introduction to C++ Programming and Graphics The following code introduces a new pointer and evaluates its content: #include ...
5.6 Pointers to free memory 147 return 0; } Running the code produces the system-failure message: Segmentation fault However, ru ...
148 Introduction to C++ Programming and Graphics return 0; } The output is: 0x917e008 0x917e008 To free memory, we can delete th ...
«
3
4
5
6
7
8
9
10
11
12
»
Free download pdf