CS253 IQ 03
Show Main.IQ03 as a slide show.
Parameter Passing
By default, how are scalars, arrays, and objects passed to functions?
- scalars by reference, others by value
- scalars by value, others by reference
- arrays by reference, others by value
- arrays by value, others by reference
- objects by reference, others by value
- objects by value, others by reference
What will this display?
cout << reinterpret_cast<long>("-123");
4196472
- the
long
123
- the
long
−123
- the
long
4
- the
const char * "-123"
- none of the above
A C string is terminated by:
- a newline
- control-D
- control-Z
- a null character
nullptr
- Ahhhnold
A std::string
has a maximum length of:
- 255
- 32767
- the maximum value of an
int
- there is no maximum length
- none of the above
How do you get a std::string
to work with?
string s;
string s = new string;
new string s
;
string s = new string(40); // 40-char string
For any string
, which is always true?
.capacity()
≤ .max_size()
≤ .size()
.capacity()
≤ .size()
≤ .max_size()
.max_size()
≤ .capacity()
≤ .size()
.max_size()
≤ .size()
≤ .capacity()
.size()
≤ .capacity()
≤ .max_size()
.size()
≤ .max_size()
≤ .capacity()
string s{"Fluttershy"};
cout << s.capacity() << ' ' << s.max_size() << ' ' << s.size();
15 9223372036854775807 10