< previous page
page_1038
next page >
Page 1038
what does the following statement do?
r = 2 * r;
a. It doubles the contents of
n
.
b. It doubles the contents of
r
.
c. It doubles the contents of the variable that n points to.
d. It doubles the contents of both
r
and
n
.
e. Nothingit results in a compile-time error.
8. Define the following terms:
deep copy
shallow copy
class destructor
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
class TestClass
{
public:
void Write();
TestClass( /* in */ int initValue );
~TestClass();
private:
int privateData;
};
suppose that the member functions are implemented as follows:
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;
}
What is the output of the following program?
< previous page
page_1038
next page >