Quiz #2 Hints - CS 170A Quiz #2 Hints DigiPen Institute of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Quiz #2 Hints Name DigiPen Institute of Technology April 21, 2006 In all of the following questions, assume that only the iostream header file has been included, and that the std namespace is being used. 1. Consider the following class definition. class A { public: A(void) : value(4) { cout << "A"; } A(int n) : value(n) { cout << "B"; } A(const A& a) : value(a.value+5) { cout ~A(void) { cout << "D"; } { value += a.value; return *this; } int operator[](int i) const { return value+i; } private: int value; }; (a) What is printed as a result of the following code fragment? A a; cout << a[8]; Use the default constructor and the subscripting operator. (b) What is printed as a result of the following code fragment? A *p = new A(2); cout << (*p)[6]; delete p; Use the non–default constructor, the subscripting operator, and the destructor. (c) What is printed as a result of the following code fragment? A a(7);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2008 for the course CS 170 taught by Professor Hanson during the Spring '06 term at DigiPen Institute of Technology.

Page1 / 2

Quiz #2 Hints - CS 170A Quiz #2 Hints DigiPen Institute of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online