Software and errors (part 2)
This lesson contains approximately 25 minutes of video content.
Compile-time errors
Link-time errors
Runtime errors
Logic errors
Questions
Q1
QS&E Pt. 2, Q1
This question is ungraded.
Given the following error message:
tmp.cc:8:9: error: invalid operands to binary expression ('double' and 'int')
What line number does the compiler suggest the error on? Write your answer as a single integer value.
Q2
QS&E Pt. 2, Q2
This question is ungraded.
The following error reported by the compiler:
tmp.cc:8:32: error: unexpected ':' in nested name specifier; did you mean '::'?
is what kind of compile-time error introduced in the lesson?
Q3
QS&E Pt. 2, Q3
This question is ungraded.
The following error reported by the compiler:
error: invalid operands to binary expression ('std::string' (aka 'basic_string') and
'std::string')
is what kind of compile-time error introduced in the lesson?
Q4
QS&E Pt. 2, Q4
This question is ungraded.
The following error message:
/tmp/tmp-f45386.o: In function `main:
tmp.cc:(.text+0x13): undefined reference to `Mult(int x, int y)'
tells you what? Select the best answer.
Q5
QS&E Pt. 2, Q5
This question is ungraded.
The following error message:
duplicate symbol '_main' in:
/var/folders/37/z3gfdt9x0tvg0pr1drljxk0w0000gn/T/ex1-f27d44.o
/var/folders/37/z3gfdt9x0tvg0pr1drljxk0w0000gn/T/ex2-ac8acf.o
ld: 1 duplicate symbol for architecture x86_64
tells you what? Select the best answer.
Q6
QS&E Pt. 2, Q6
This question is ungraded.
The following error message communicates a run-time error:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
What happened? Select the best answer.
Q7
QS&E Pt. 2, Q7
This question is ungraded.
The following function has a logic error:
int LargestValueInVectorInt(const std::vector<int>& values) {
int max = 0;
for(int idx = 0; idx < values.size(); ++idx) {
if (max < values.at(idx))
max = values.at(idx);
}
return max;
}
On what line number does the logic error present? Enter the line number as an integer value.