Answer the question
In order to leave comments, you need to log in
What does the program print and why?
#include <iostream>
using namespace std;
struct A{
A(){cout<<"A";}
A(A&){cout<<"B";}
virtual void f(){cout<<"C";}
};
int main() {
A a[10];
std::cout<<'\n';
for(auto x: a)
{
x.f();
}
}
Answer the question
In order to leave comments, you need to log in
Program prints
AAAAAAAAAA
BCBCBCBCBCBCBCBCBCBC
A a[10];
for(auto x: a)
x.f();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question