Xref: utzoo comp.lang.c++:13582 comp.std.c++:925 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!news.uu.net!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: Constructor Limitation: [Was: Re: Constructor question] Message-ID: <72461@microsoft.UUCP> Date: 20 May 91 20:59:57 GMT References: <1991Apr2.110623.22219@and.cs.liv.ac.uk> <20164@alice.att.com> <1991Apr18.005426.21863@dragon.wpd.sgi.com> <71952@microsoft.UUCP> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 29 In article dsouza@gwen.cad.mcc.com (Desmond Dsouza) writes: > You cannot compute any temporaries (e.g. common subexpressions) > which are needed for initialization of such data members. Consider: ---- int F1(int j) { /* something really really big and horrible here */ return j;} class A { public: A(int m, int n); }; class B { public: B (int j); private: int f1; A a1; // initialized with F1(j), F1(j)+1 for some horribly complex F1 }; B::B(int j) // how can I share the computation of F1(j) here ??? !!! Try the following: : f1(F1(j)), a1(f1, f1+1) { // this part does not help: I cannot modify a1 at this point. }