12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Day 3<br />

Day 4<br />

Answers to Quiz Questions<br />

1. A po<strong>in</strong>ter is a variable that holds the address of another variable or an object <strong>in</strong><br />

memory.<br />

2. To de-reference a po<strong>in</strong>ter means to get the value of the variable that the po<strong>in</strong>ter<br />

po<strong>in</strong>ts to and not the value of the po<strong>in</strong>ter itself (which is just a memory location).<br />

3. The memory address where the newly created object resides.<br />

4. Usually classes and structures should be passed by reference to elim<strong>in</strong>ate unnecessary<br />

overhead.<br />

5. The const keyword prevents a variable from be<strong>in</strong>g modified.<br />

6. No. Overloaded functions must vary by the type and number of parameters. These<br />

two functions vary only by return type.<br />

7. It depends on the situation. No one situation is best every time. This is a trick<br />

question.<br />

8. A class member function is a function that belongs to a class.<br />

9. The compiler will place the entire contents of the <strong>in</strong>l<strong>in</strong>e function <strong>in</strong> the compiled<br />

code each time the <strong>in</strong>l<strong>in</strong>e function is encountered <strong>in</strong> the source code. In the case of<br />

a regular function, the function exists <strong>in</strong> the compiled code only once, and the<br />

compiler places a call to the function each time the function is encountered <strong>in</strong> the<br />

source code.<br />

10. The function should use the delete[] form of operator delete:<br />

delete[] buff;<br />

1. In <strong>C++</strong> a structure is simply a class <strong>in</strong> which all data members and functions have<br />

public access by default. Aside from that, there is no difference.<br />

2. Private data members protect data from be<strong>in</strong>g modified directly by users of the<br />

class. Private data members can be modified through public member functions but<br />

not directly.<br />

3. By us<strong>in</strong>g getters and setters, which are public member functions that can be called<br />

to change the value of a private data member.<br />

4. The destructor is called when the object is destroyed. For local objects this will<br />

occur when the object goes out of scope. For dynamically allocated objects this will<br />

occur when the object is deleted.<br />

503<br />

A

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!