#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();
}
a) 3
b) 4
c) 2
d) 1
In the following C++ code how many times the string “A’s constructor called” will be printed?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
In the following C++ code how many times the string “A’s constructor called” will be printed?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!