class Base
{
public:
int i;
Base(int j):i(j){}
};
int main()
{
Base B(10);
Base C[10](B);//throws error saying bad array initializer
}
When I tried to compile this code, above mentioned error was thrown.
Why doesn't C++ compile this code?
Why can't each object call it's default copy constructor and use the member value of B?
Am I missing something in the C++ standard?
std::vector<Base> v(10, Base(10));Base C[10]{B, B, B, B, B, B, B, B, B, B};Maybe you can write a macro to generate the code for correct number of copies...