Вы находитесь на странице: 1из 2

NOTE: name of an array is address of its first element. But cout << t where char t[23] = "..

" shows the string in t. I.E., if you give cout the address of a cha racter, it prints everything from that character to the first null character tha t follows. So t is address of a char. This implies that you can use a pointer-to-char varia ble as an argument to cout, because it too is an address of a char. (Page 185) Using (int *) to print address of string: Page 188. Using char* to get string input: bottom of page 192. All page numbers are on the Adobe interface, not the page design. In which situations should you use references or pointers or standard pass-by-va lue parameters? Bottom of page 384. Avoiding multiple compilations of same header file: page 419 Using global variables from another file: page 434 When to use namespaces (instead of global variables, etc.): page 460. How to make functions constant in classes (so that constant class objects can be used in all cases): page 498 The "this" pointer: page 501/502. Static variables in class (or static class members): just one created for all ob jects of class. Page 587 Freeing memory used by pointer: end of page 175. Operator overloading: syntax is operatorOP(arguments). For example: Time Time::o perator+(Time &t) See page 531. In a binary operator with declaration such as Time Time::operator*(int n), the c orrect usage is time * 500 where time is a Time object. Incorrect to use 500 * t ime (Page 538) Don't need to pass by reference an array if you want to alter it as passing by v alue the array name will suffice (remember arrayName is a pointer). For protecting function arguments with const: page 322. Using pointers and const: page 328 Pointers to functions: if you have a function declaration: double pam(int), a pointer to it can be decl ared as: double (*pf)(int). Then pf = pam sets the pointer to the function. If you have a class, and that class has a function which accepts an argument of the same type as the class, then in the class def. you can access the argument's private members. (Page 498): if you have a function such as "void show()" in a class and that fun ction doesn't change the invoking object, then write "void show() const" to tell compiler that it doesn't.

Friend functions: non-member function of a class but has access to class' privat e data. Used in situations such as: A = 2*B; where B is a class (which is on the RHS). Syntax: declaration: friend Class operator*(int LHS, typeOfB RHS); defn: Class operator*(int LHS, typeOfB RHS) { Note there is no const after the arguments. Need to use friend in this case caus e you can't write the int::operator*(..) method

Вам также может понравиться