perry@key.COM (Perry The Cynic) (02/16/91)
Consider the following program: class One { friend class Two; private: One(); }; class Two { static One test; } One Two::test; The last line draws an error from both cfront and Turbo C++: error: ..() cannot access One::One(): private member Why the complaint? My interpretation of the scoping rules says that the Two:: qualifier puts me into Two's scope. Since Two is a friend of One, I don't see why it can't access One's private constructor. Incidentally, the error remains even if I rewrite the last line as One Two::test = One(); and the ARM says explicitly that the initializing expression is interpreted in the context of Two. What am I misunderstanding here? Can somebody quote the language rule that I'm missing? Or are both compilers violating the language standard? Oh, and how do I write this legally? The intent is to make it impossible to create objects of type One, except inside Two (which then hands out references to One objects). Thanks -- perry -- -------------------------------------------------------------------------- Perry The Cynic (Peter Kiehtreiber) perry@arkon.key.com ** What good signature isn't taken yet? ** {amdahl,sgi,pacbell}!key!perry