Home / MCQ Bank / Computer
Computer Constructors And Destructors In C Plus Plus

In the following C++ code how many times the string "A's constructor called" will be printed? #include <iostream> #include <string> using namespace std; class A{ int a; public: A(){ cout<<"A's constructor called"; } }; class B{ static A a; public: B(){ cout<<"B's constructor called"; } static A get(){ return a; } }; A B::a; int main(int argc, char const *argv[]) { B b; A a1 = b.get(); A a2 = b.get(); A a3 = b.get(); }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option D • 1

Related Computer Questions

What returns a result to the client? Arrays in Java are implemented as? Which of the following type attributes of input element defines control for entering a telephone number? The ______ is a framework-specific entity that negotiates resources from the ResourceManager. Which of the methods are used to manage result sets using both associative and indexed arrays?