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~~"<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

 

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; }

}

  1. We can tell for certain what type of variable match is.

  2. We can tell that on_off is a function in the Candle class.

  3. light_candle is an overridden function.

  4. 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.

  1. We can assume on_off will always have the value true when light_candle is called since we are passing in by reference.

  2. We can assume that match is in the Candle class.

  3. r.light_candle(true, can1); would be a possible valid line of code.

  4. light_candle(true, can1); would be a possible valid line of code.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education