Answer the following true/false questions using the following code. And state why it is true or false . Code fragment 1: void light_candle(Candle &c) { if(match){ cout << "~~Lighting candle indoors~~"<
Answer the following true/false questions using the following code. And state why it is true or false .
Code fragment 1:
void light_candle(Candle &c)
{ if(match){
cout << "~~Lighting candle indoors~~"<<endl; c.on_off=true;
match=false;
} else{
cout <<"You don't have a match."<<endl; }
}
void light_candle(bool weather, Candle &c)
{
if(weather&&match) {
cout << "~~Lighting candle outdoors~~"<<endl; c.on_off=true;
match=false;
}
else{
cout << "Too hot to light candle."<<endl; }
}
-
We can tell for certain what type of variable match is.
-
We can tell that on_off is a function in the Candle class.
-
light_candle is an overridden function.
-
If we have a Candle object called can1, can1.match would be valid line of code.
5. We see two examples of polymorphism in this given code.
-
We can assume on_off will always have the value true when light_candle is called since we are passing in by reference.
-
We can assume that match is in the Candle class.
-
r.light_candle(true, can1); would be a possible valid line of code.
-
light_candle(true, can1); would be a possible valid line of code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Recommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education