7. Given the code below, answer the questions. class TestQuestion I Line 1 II in
ID: 3892858 • Letter: 7
Question
7. Given the code below, answer the questions. class TestQuestion I Line 1 II ine 2 ILine 3 II Line 4 I Line s II Line 6 string nane; int number public: TestQuestion) TestQuestion(const string&, int ) TestQuestion(const TestQuestion&) -TestQuestion); II Line 7 string ToString()const; TestQuestion& operator-(const TestQuestion&); void SetName(const string8) Line 8 II Line 9 II Line 10 int GetNumber)const; II Line 11 II Line 12 The variables in Line 2 and 3 are called b. The functions in Line 5 through 12 are called: The keyword in Line 4 is c. known as a: d. The functions in Lines 5,6 and 7 are: The function in Line 5 is a: e· The function in Line 7 is a: The function in Line 8 is a: h. The function in Line 10 is a: 1· The function in Line 1 1 is a: j· The function in Line 12 is a: f. g. This class requires, without doubt, the functions in lines 7 8 and 10 (True or False) · 8. You are going to change the world by writing the best C++ sort function ever. Name yout BestSort. You will need to pass information about the array using parameter(s) so tha returns, the array of integers will be sorted. Note that your function needs to work for any your function wil never fail, it will not return anything. Write a function prototype for yExplanation / Answer
ANS:
a. private variables of class TestQuestion.They are set by SetName function,
b. line 5 is called default constructor.Line 12 is the GetNumber() is used to get number from class.
c.public is the access specifier which is used to specify the access of class.
d. Line 5: default constructor -as there are no parameters
Line 6: parameterised constructor-as parameters are sent as arguments
Line 7: copy constructor as we sent same class object as parameter
e.Line 5:Default Constructor-called when creating object from class TestQuestion without any parameters
f.Line 7:Copy COnstructor.It will called when an already created object of class TestQuestion
is used to create new object of class TestQuestion.
g. Line 8 : Destructor.It will be automatically called when object is deleted or program is exited
h) Line 10:Operator overloading of operator "="
called when we want to assign one object's values to another object class TestQuestion.
i)Line 11 : is used to set "name" variable of class by setName function.
j)Line 12 :is used to get number from object of that class
k.)FALSE since Line 7: parameterised constructor,Line 8: Destructor,Line 10 - "="operator overloading
is not essential for a class as there will be default to take care of those.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.