The following copy constructor on lines 2-8 has a few bugs (errors). List all of them in the text box provided with the provided line number as a reference. For example, line 13 is missing a semi-colon (do not use this as one of your answers, -3.5 points). 1 class Midterm{ 2 void Midterms(const Midterm m){ 3 _scores = new int[_class_size]; 4 _class_size = m._class_size; 5 for(int i = 0; i < m._class_size; i++) 6 _scores[i] = m._scores[i]; 7 delete[] m._scores; 8 }//Midterm 9 10 private: 11 int _class_size = 0; 12 int* _scores = nullptr; 13}//Midterm
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
The following copy constructor on lines 2-8 has a few bugs (errors). List all of them in the text box provided with the provided line number as a reference. For example, line 13 is missing a semi-colon (do not use this as one of your answers, -3.5 points).
1 class Midterm{
2 void Midterms(const Midterm m){
3 _scores = new int[_class_size];
4 _class_size = m._class_size;
5 for(int i = 0; i < m._class_size; i++)
6 _scores[i] = m._scores[i];
7 delete[] m._scores;
8 }//Midterm
9
10 private:
11 int _class_size = 0;
12 int* _scores = nullptr;
13}//Midterm
Trending now
This is a popular solution!
Step by step
Solved in 3 steps