Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!pp!pink!rfg From: rfg@pink.ACA.MCC.COM (Ron Guilmette) Newsgroups: comp.lang.c++ Subject: initialization of private members Message-ID: <268@pink.ACA.MCC.COM> Date: 2 Jul 89 21:07:16 GMT Reply-To: rfg@MCC.COM (Ron Guilmette) Organization: MCC Austin, Texas Lines: 36 Anyone care to tell me if the indicated line is an error or not? I believe that it should be considered an error whenever you try to set the value of a private member if the attempt is made from *outside* a member function of the given class. What do y'all think? --------------------------------------------------------------------- // Check that initialization of private data members is illegal // except via the use of an explicit constructor. class friendly; class base { int data_member_1; // private data member public: int data_member_2; friend class friendly; // prevent warnings void function_member (); }; void test () { base object = { 3, 5 }; // ERROR object.function_member (); // prevent warnings } --------------------------------------------------------------------- -- // Ron Guilmette - MCC - Experimental Systems Kit Project // 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740 // ARPA: rfg@mcc.com // UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg