< previous page page_1038 next page >

Page 1038
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
what does the following statement do?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
r = 2 * r;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. It doubles the contents of n.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. It doubles the contents of r.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. It doubles the contents of the variable that n points to.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
d. It doubles the contents of both r and n.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
e. Nothingit results in a compile-time error.
8. Define the following terms:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
deep copy
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
shallow copy
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
class destructor
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
class copy-constructor
9. By default, C++ performs both assignment and initialization of class objects using shallow copying. (True or False?)
10. Given the class declaration
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
class TestClass
{
public:
    void Write();
    TestClass( /* in */ int initValue );
    ~TestClass();
private:
    int privateData;
};
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
suppose that the member functions are implemented as follows:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
void TestClass::Write()
{
    cout << Private data is  << privateData << endl;
}

TestClass::TestClass( /* in */ int initValue )
{
    privateData = initValue;
    cout << Constructor executing << endl;
}

TestClass::~TestClass()
{
    cout <<  Destructor executing << endl;
}
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
What is the output of the following program?

 
< previous page page_1038 next page >