Question: Question Goal: Learn how to declare and instantiate objects using class constructors. Assignment: Below you have a Timer class defined. Instantiate a Timer object called

Question
Goal: Learn how to declare and instantiate objects using class constructors.
Assignment: Below you have a Timer class defined.
Instantiate a Timer object called timer1 with the countdownTime data field equal to 30;
Instantiate a Timer object called timer2 with the countdowntime data field equal to 90;
Instantiate a Timer object called timer3 with the countdowntime data field equal to its default value.
class Timer
{
public:
int countdownTime;
Timer()
{
countdownTime=60;
}
Timer(int value)
{
countdownTime = value;
}
void tick()
{
if (countdownTime >0)
{
countdownTime--;
}
}
};
My current code:
Timertimer1(30);
Timertimer2(90);
Timertimer3;
Note: my code is compiling correctly and getting the correct output. For some reason I am getting an error about assignment requirements where I have a missing newline at the end of the file.
I am also having this issue and tried doing the solution of adding a newline but it doesn't work at all. Wanted to get a second opinion from someone else. Please help.
Question Goal: Learn how to declare and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!