CS253: Software Development with C++

Spring 2020

IQ 08

CS253 IQ 08

Show Main.IQ08 as a slide show.

Reflection

int zulu;
cout << typeid(zulu).name() << '\n';
i

What will this code emit?

  1. int zulu
  2. int
  3. zulu
  4. i
  5. It cannot be determined.

Sure, gcc returns 'i', but it’s implementation-defined.

Virtual Inheritance

What problem does virtual inheritance address?

  1. Stroustrup’s Syntax Sin
  2. Polymorphic Pointers
  3. Namespace Numbering
  4. Method Mangling
  5. Dreaded Diamond

Dreaded Diamond: A inherits from B & C, B & C both inherit from D.

Programming Paradigms

Which statement is true?

  1. Makefiles are event-driven.
  2. C++ is event-driven.
  3. Spreadsheets are imperative.
  4. Graphics programs are declarative.
  5. Object files are declarative.

C++ can operate in any of these modes; nearly all programs are somewhat imperative. The best answer is that Object files are declarative, IMHO.

Exceptions

What sort of argument can throw take?

  1. only std::Exception and classes derived from it
  2. any scalar or object
  3. any scalar or copy-constructable object
  4. any object
  5. any copy-constructable object

anything: any scalar, any object

Exceptions

int main() {
    throw 42;
    cout << "honeybee\n";
}
terminate called after throwing an instance of 'int'
SIGABRT: Aborted

🐝

What will this program display?

  1. 42
    honeybee
    an error message
  2. honeybee
    an error message
  3. an error message
    honeybee
  4. honeybee
  5. an error message

Once it throws, nothing else happens in that code.