Why this code can't compile? If i'll change copy constructor access level to public, it'll be ok and print "Foo::Foo(int)". If i'll write "Foo instance(0);" instead of "Foo instance = 0;" it'll also ok. Why? And what's the point of this behavior?
#include <iostream>
struct Foo
{
public:
int i;
Foo(int i) : i(i) { std::cout << "Foo::Foo(int) \n"; }
private:
Foo(const Foo&) { std::cout << "Foo::Foo(const Foo&) \n"; }
};
int main()
{
Foo instance = 0;
}