A Moving to another question will save this response. Question 55 What is the ou
ID: 3580696 • Letter: A
Question
A Moving to another question will save this response. Question 55 What is the output of the following code snippet? include kiostream using namespace std, class Building public: Building(); void set height (double count), void get data() const private: double height; Building: Building cout "Constructor endl void Building: :get data() const cout height endl; void Building: set height (double count) height count; int main() Building blg1; Building blg23 height (10) blg2 set height (50) bl.g1.get dataExplanation / Answer
Class Building contains:
1. Default Constructor that simply prints the string "Constructor" to console.
2. Function set_height that assigns the value to member variable height.
3. Function get_data() that returns the value of the variable height.
-----------------------------------------------------------------------------------------
In main:
//Creates an object of class Building. -> Prints Constructor to console
Building blg1;
//Creates an object of class Building. -> Prints Constructor to console
Building blg2;
//Assigns the value of height to 10 for blg1 instance
blg1.set_height(10);
//Assigns the value of height to 50 for blg2 instance
blg2.set_height(50);
//Prints the value of height variable using blg1 instance -> Prints 10 to console
blg1.get_data();
//Prints the value of height variable using blg2 instance -> Prints 50 to console
blg2.get_data();
So output of the program will be:
Constructor
Constructor
10
50
Hence correct option is (A)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.