From previous post, I learnt that for there are two ways, at least, to declare an array without default constructors. Like this
class Foo{
public:
Foo(int i) {}
};
Foo f[5] = {1,2,3,4,5};
Foo f[5] = {Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)};
I also learnt that the first one will construct the object using the parameter directly and the second copy constructor is used here. However, when I test the code below. I make the copy constructor private. I expect to see the difference of the copy constructor usage. But it is not what I expected. Neither of the two declarations is working.
class Foo{
public:
Foo(int i) {}
private:
Foo(const Foo& f) {}
};
int main(){
Foo f[5] = {1,2,3,4,5};
Foo f[5] = {Foo(1), Foo(2), Foo(3), Foo(4), Foo(5)};
}
Can anybody explain to me why does this happen?