CS253: Software Development with C++

Fall 2018

IQ 06

CS253 IQ 06

See this page as a slide show

is-a

class Unikitty { };
class Puppycorn : public Unikitty {
    int dr_fox;
};

Which of these is true?

  1. Unikitty is-a Puppycorn
  2. Unikitty is-a dr_fox
  3. Puppycorn is-a Unikitty
  4. Puppycorn is-a dr_fox
  5. dr_fox is-a Unikitty
  6. dr_fox is-a Puppycorn

has-a

class Unikitty { };
class Puppycorn : public Unikitty {
    int dr_fox;
};

Which of these is true?

  1. Unikitty has-a Puppycorn
  2. Unikitty has-a dr_fox
  3. Puppycorn has-a Unikitty
  4. Puppycorn has-a dr_fox
  5. dr_fox has-a Unikitty
  6. dr_fox has-a Puppycorn

Inheritance

Can private methods in a derived class call private methods in the base class?

  1. Yes, a derived class has full access to the base class methods.
  2. Yes, if the base class methods are declared as public in the derived class.
  3. No—private!

--

Which method is the best way to make Foo f; f--; work?

  1. operator--()
  2. operator--(int)
  3. Foo operator--()
  4. Foo operator--(int)
  5. Foo &operator--()
  6. Foo &operator--(int)

stringstream

What will this code produce?

ostringstream oss;
oss = "Flying Spaghetti Monster";
cout << oss.str();
c.cc:2: error: no match for 'operator=' in 'oss = "Flying Spaghetti Monster"' 
   (operand types are 'std::ostringstream' {aka 
   'std::__cxx11::basic_ostringstream<char>'} and 'const char [25]')
  1. Flying
  2. Flying Spaghetti Monster
  3. 6
  4. 24
  5. None of the above

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2018-07-11T15:26

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building