Question: Write a program that creates test attempts by taking two inputs from the users: number of questions in the test Question numbers, space separated that
Write a program that creates test attempts by taking two inputs from the users:
number of questions in the test
Question numbers, space separated that were correct in the TestAttempt.
main.cpp
Reads num of questions in the test from the user.
Read the correct answers for attempt which are space separated question numbers which are right.
Read the correct answers for attempt which are space separated question numbers which are right.
Print both attempt and attempt You need to overload the stream operator to print.
Copy attempt into a temp object and print temp. calls copy constructor
Copy attempt into a temp object and print temp calls copy constructor
Assign attempt to an existing object temp and print temp calls assignment operator
Use operator for attempt and attempt and print the result.
Use operator for attempt and attempt and print the result.
Class Description
TestAttempt.h
You need to be able to copy test attempts deep copy and assign test attempts along with printing your attempt object. So you need to overload the following functions in TestAttempt class.
Member fields:
numQuestions: total number of questions in the test.
results: a dynamic boolean array initialized to false for all the questions and only set to true if user gives a correct answer.
TestAttempt attempt;
numOfQuestions
results is an array with fields T T T T T F F F
Member functions:
Constructor: parameterized constructor.
copy constructor: allows copying of test attempt objects.
TestAttempt attempt;
TestAttempt attempt attempt; calls copy constructor
TestAttempt attemptattempt; calls copy constructor
operator: copies the data from rhs to lhs object Note: the lhs object should be existing already, if you create a new object it calls copy constructor
attempt attempt copies attempt into attempt uses operator
outputstream operator: If you use cout with attempt, it prints the results array as follows
cout
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
