I am having a hard time trying to figure out why this code seems to work. Shouldn't I get an "array initializer must be an initializer list" error?
#include <iostream>
class B {
public:
B() { std::cout << "B Constructor " << std::endl ; }
B(const B&) { std::cout << "B Copy Constructor " << std::endl ; }
~B() { std::cout << "B Destructor " << std::endl ; }
} ;
class A {
public:
A() { std::cout << "A Constructor " << std::endl ; }
A(const A& other) : bs(other.bs)
{ std::cout << "A Copy Constructor " << std::endl ;}
~A() { std::cout << "A Destructor " << std::endl ; }
private:
B bs[12] ;
};
int main() {
A a ;
A b(a) ;
return 0 ;
}
The output of g++ --version
is g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)