0

You are making a Quiz game. The Quiz class inherits from the Game base class. Both classes have constructors, which output a S

You are making a Quiz game. The Quiz class inherits from the Game base class. Both classes have constructors, which output a Start message. Create destructors for each class, which will output "Game Over" in the Game class, and "Quiz Over" in the Quiz class, so that when the program executes, it outputs: Game Started Quiz Started Quiz Over Game Over #include <iostream> using namespace std; class Game { public: Game() { cout<<"Game Started"<<endl; } ~Game() { cout<<"Game Over"<< endl; } }; class Quiz: public Game { public: Quiz() { cout<<"Quiz Started"<<endl; } ~Quiz() { cout<<"Quiz Over"<<endl; } }; int main() { Quiz q; } my code doesnt seem to work, an error is : timeout: failed to run command usercode/a.out :

16th Nov 2022, 9:39 AM
Rachel Pangemanan
1 Resposta
0
Heyhey so i try to help: the main function has to be outside your game class cause thats the startpoint the compiler looking for if you wrap this in a class the compile disnt acces them cause its hiding from and while the main function has a return value type int you have to return a int so do the following: Class Game{ *here your class code* } Class Quiz: Game{ *your quiz code here } Int main(){ Quiz q; q.Quiz(); return 0; } That should fix the problem Hope that helps, immay see some other issue in your code but iam not to comfortable with c++ the class innerhitance should be class Quiz : Game {} Maybe a better c++ dev is out there to submit my guess Happy coding 👌😉
27th Nov 2022, 3:50 PM
S3R43o3
S3R43o3 - avatar