CS253 IQ 06
Show Main.IQ06 as a slide show.
is-a
class Unikitty { };
class Puppycorn : public Unikitty {
int dr_fox;
};
Which of these is true?
Unikitty
is-a Puppycorn
Unikitty
is-a dr_fox
Puppycorn
is-a Unikitty
Puppycorn
is-a dr_fox
dr_fox
is-a Unikitty
dr_fox
is-a Puppycorn
has-a
class Unikitty { };
class Puppycorn : public Unikitty {
int dr_fox;
};
Which of these is true?
Unikitty
has-a Puppycorn
Unikitty
has-a dr_fox
Puppycorn
has-a Unikitty
Puppycorn
has-a dr_fox
dr_fox
has-a Unikitty
dr_fox
has-a Puppycorn
Inheritance
Can private
methods in a derived class call private
methods in
the base class?
- Yes, a derived class has full access to the base class methods.
- Yes, if the base class methods are declared as
public
in the derived class.
- No—
private
!
--
Which method is the best way to make Foo f; f--;
work?
operator--()
operator--(int)
Foo operator--()
Foo operator--(int)
Foo &operator--()
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]')
Flying
Flying Spaghetti Monster
6
24
- None of the above