CS253 IQ 07
Show Main.IQ07 as a slide show.
Cañon City
How many bytes are needed for the “a” in “Cañon City”?
- 0
- 1
- 2
- 3
- 4
cout << "a"s.size() << '\n';
1
Cañon City
How many bytes are needed for the “ñ” in “Cañon City”?
- 0
- 1
- 2
- 3
- 4
cout << "ñ"s.size() << '\n';
2
Cañon City
What will this code display?
string s = "Cañon City";
cout << s[4] << '\n';
o
- C
- a
- ñ
- o
- n
What problem do virtual functions deal with?
- Fireball
- Invisibility
- Polymorphism
- Regeneration
- Simulacrum
Which of these is correct?
class Base { };
class Derived : public Base { };
Base *b = …;
Derived *d = …;
b = dynamic_cast<Base *>(d);
b = dynamic_cast(Base *, d);
b = dynamic_cast(d);
d = dynamic_cast(b);
d = dynamic_cast<Derived *>(b);
d = dynamic_cast(Derived *, b);
Any problems with this code?
#ifndef FOO_H_INCLUDED
#include "otherfile.h"
#include <string>
class Foo {
…
};
#define FOO_H_INCLUDED
#endif
- It’s fine.
- The
#ifndef
should be #ifdef
.
- The
define
is in the wrong place.
- It’s unnecessary—include guards are no longer required
in modern compilers.