views:

39

answers:

2

Possible Duplicate:
How to use a object whose copy constructor and copy assignment is private?

In reading TCPL, I got a problem, as the title refered, and then 'private' class is:

class Unique_handle {
private:   
    Unique_handle& operator=(const Unique_handle &rhs);  
    Unique_handle(const Unique_handle &rhs); 
public:
    //...
} 

The using code is:

struct Y {
    Unique_handle obj;
};

And I want to do such operations

main()
{
    Y y1;
    Y y2 = y1;
    return 0;
}

although, these code are come from TCPL, but I still can not got the solution... Can anybody help me, appreciate.

A: 

I forgot a ';' in first class definition, but it doesn't matter...

coanor
There aren't forums, but a Q and A site. Your question remains on top and people post answers to it, ranked. Just edit your question to fix mistakes. (And delete this "answer".)
GMan
+1  A: 

Evidently you need "friend" declarations in that class, or that class already has static accessors that will create or even assign the instance you need.

Brent Arias
Thank you very much, I'm just a beginner of stackoverflow, but as you suggestion, I have learned the format of question. Thank you again, forgive my poor English,plz...
coanor