Find 3 errors in the code below. Assume that the code is completely shown except
ID: 3838188 • Letter: F
Question
Find 3 errors in the code below. Assume that the code is completely shown except for #includes and "using namespace std". For each error, identify whether it is a runtime error, syntax error or logic error. You must also precisely describe why you think the part of code you identify is an error. class Problem8 private: Problem8* ptr; public: Problem 8() "Problem 8(); Problem8(Problem8 x); }; Problems8: Problem8() { ptr = new Problem8[10]; } Problem8:: "Problem8() { delete [] ptr; } Problem 8:: Problem8 (Problem8 x) { ptr = new Problem8[10]; for (int i = 0; iExplanation / Answer
[1] Logical Error
main.cpp:11:22: error: invalid constructor; you probably meant 'Problem8 (const Problem8&)'
Problem8(Problem8 x);
[2]
main.cpp:22:1: error: prototype for 'Problem8::Problem8(Problem8)' does not match any in class 'Problem8'
Problem8::Problem8(Problem8 x){
^
[3]
main.cpp:5:7: error: candidates are: Problem8::Problem8(const Problem8&)
class Problem8{
^
[4]
main.cpp:14:1: error: Problem8::Problem8()
Problem8::Problem8(){
^
main.cpp: In function 'int main()':
[5] Complie Time Error
main.cpp:7:13: error: 'Problem8* Problem8::ptr' is private
Problem8* ptr;
^
[6]
main.cpp:33:4: error: within this context
x.ptr[0] = x.ptr[9];
^
[7]
main.cpp:7:13: error: 'Problem8* Problem8::ptr' is private
Problem8* ptr;
^
[8] Run Time
main.cpp:33:15: error: within this context
x.ptr[0] = x.ptr[9];
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.