if string s = "I like apples"; what does s.length(); return?
void
Declare a vector of integers V of size n (n is an integer variable previously declared and initialized)
vector <int> V(n);
if string s = "We are in the endgame now D:". How do I use substr to get "engame"?
s.substr(14, 7);
Given a function sum of the form int sum(int, int). Give an example of an incorrect way to call sum.
One possible answer: sum(1,"2");
How you access the last element of a vector V of size n where n is an integer variable previously declared and initialized
v.at(n - 1);
if string s = "I don't wanna go". What does s.find('i') return?
Given a function of the form int f(int x, int &y). Give an example of an invalid way to call f.
["", "hi", ""]
what are the parameters to the replace function from the string library?
Starting index
Number of characters to replace
String to replace with
Explain the main benefit of using pass by reference parameters.
Using pass by reference parameters, we avoid copying large amounts of data.
string s = "1.2.3.4.5";
s.replace(s.find(".2") + 1, 2, ".3");
What is stored in s?
1..33.4.5
Explain why sometimes pass by reference parameters are also constants.