1. Why could C++ have not disabled a default copy constructor and why shouldnt it have demanded a
explicit copy constructor, if such a use case of the class exist, it would have avoided possibility of unintended double destruction.
2. Why couldnt c++ have prevented operator overloading in global scope or non-class scope? May be it was needed for friends??
3. Couldnt it have dealt the friend problem by allowing a friend override in the declaration of a class on a argument list or a member declaration??(so wouldnt have required friend global operator overloading, and wouldnt have required c-functions access to private members. ) (but if friendship was not supposed to be taken but given, is there still a solution?)
4. was namespaces really necessary, when class/struct where sufficient?

What is the output of the following? What value do such constructs add?
#include <iostream>
using namespace std;
namespace space1
{
class A
{
int a;
public:
void print()
{
cout << " space1::A:rint\n";
}
};
void operator << (A& a, int b)
{
cout << "I am the space1, int operator in space1\n";
a.print();
}
};


namespace space2
{
class A
{
int a;
public:
void print()
{
cout << " space2::A:rint\n";
}
};

void operator << (A& a, int b)
{
cout << "I am the space2::A, int operator in space2\n";
a.print();
}

void operator << (space1::A &a, float b)
{
cout << "I am the space1, float in space2 \n";
a.print();
}

};
using namespace space2;
void main()
{

A a;
a<<1;
space1::A b;
b<<(int)1;
space2::A c;
c<<1;

b << (float)1.0;
}


scroll down for the output






















output:
I am the space2::A, int operator in space2
space2::A:rint
I am the space1, int operator in space1
space1::A:rint
I am the space2::A, int operator in space2
space2::A:rint
I am the space1, float in space2
space1::A:rint