You are on page 1of 7

C++ by Robert Lafore (file on desktop, search query=Robert)

1) As we noted,the function cannot access the original variable in the calling program,only the copy it created. Here it means that a copy of the actual arguments is created and then its value is copied into formal arguments (parameters). 2) Passing by reference :- An important advantage of passing by reference is that the function can access the actual variables in the calling program. Among other benefits,this provides a mechanism for passing more than one value from thefunction back to the calling program. 3) Page 184, passing value by reference (not to be confused with pointers). 4) Recursion Is it true that many versions of a recursive function are stored in memory while its calling itself? Not really. Each versions variables are stored, but theres only one copy of the functions code. Even so, a deeply-nested recursion can create a great many stored variables, which can pose a problem to the system if it doesnt have enough space for them. 5) 198- complete page 6) Remember that missing arguments must be the trailing arguments those at the end of the argument list. You can leave out the last three arguments,but you cant leave out the next-to-last and then put in the last. This is reasonable; how would the compiler know which arguments you meant if you left out some in the middle? (Missing arguments could have been indicated with commas,but commas are notoriously subject

to misprints,so the designers of C++ ignored this possibility.) Not surprisingly,the compiler will flag an error if you leave out arguments for which the function does not provide default values. 7) The scope of a variable determines which parts of the program can access it,and its storage class determines how long it stays in existence. 8) Initialization If a global variable is initialized,as in int exvar = 199; this initialization takes place when the program is first loaded. If a global variable is not initialized explicitly by the programfor example,if it is defined as int exvar; then it is initialized automatically to 0 when it is created. (This is unlike local variables,which are not initialized and probably contain randomor garbage values when they are created.) ARRAYS

1) The number in brackets must be a constant or an expression that evaluates to a constant,and should also bean integer. 2) The variable (or constant) in the brackets is called the array index. 3) read 269 and 270 highlighted parts

8. OPERATOR OVERLOADING

REVISING THE STRING PORTION, WHAT ALL ARE THE FUNCTIONS OF THE STRING CLASS, THEIR SYNTAX ETC.

----------------POINTERS IN C++-------------1) Every byte has a an address. Note it its byte and not bit. 2) hobgoblin= object of dread and anticipation=bugbear. 3) fig 10.1 pg 457 4)

5) Syntax Quibbles We should note thatit is common to write pointer definitions with the asterisk closer to the variable name than to the type. char *charptr; It doesnt matter to the compiler,but placing the asterisk next to the type helps emphasize that the asterisk is part of the variable type (pointer to char),not part of the name itself. If you define more than one pointer of the same type on one line,you need only insert the type-pointed-to once,but you need to place anasterisk before each variable name. char* ptr1, * ptr2, * ptr3; // three variables of type char* Or you can use the asterisk-next-to-the-name approach. char *ptr1, *ptr2, *ptr3; // three variables of type char*

6)

6) page 462,463,464,465 7) the name of the array is its address.

8)

9) Now we see why a pointer declaration must include the type of the variable pointed to. The compiler needs to know whether a pointer is a pointer to int or a pointer to double so that it can perform the correct arithmetic to access elements of the array. It multiplies the index valueby 2 in the case of type int,but by 8 in the case of double. 10) A reference is an alias for the variable name while during passing by pointers, the variables address is used. 11) pg 478,479 12) null character requires a byte to be stored. Must READ POINT 13 13) returns a pointer to the first element and this pointer is assigned to bobby http://www.cplusplus.com/doc/tutorial/dynamic/ 14) dot (.) is a member access operator ------------------------------VIRTUAL FUNCTIONS(PG NO.532)--------------1) The rule is that pointers to objects of a derived class are typecompatible with pointers to objects of the base class.

2) As you can see,the function in the base class is always executed. 3) The rule is that the compiler selects the function based on the contents of the pointer ptr, not on the type of the pointer,as in NOTVIRT. 4)

5) pure virtual functions 6) pg 544,545,546==vrtual classes, friend functions etc. 7) friend is a keyword. 8) a static data member 9) only the first part of this pointer.

You might also like