Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: comp.lang.c++ Subject: Re: default reference arguments Message-ID: <25DDC055.18707@paris.ics.uci.edu> Date: 17 Feb 90 21:21:25 GMT References: Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Distribution: comp Organization: UC Irvine Department of ICS Lines: 29 In article turner@s44.csrd.uiuc.edu (Steve Turner) writes: >I have a relatively simple question that I can't seem to find the >answer to in my copy of Lippman or Stroustrup, and doesn't have a >simple answer that I can think of. To wit: > >How do you declare the initializer for a default reference argument, >particularly if the default value is a member of the same class? The >following code fragment should make this more clear. > >class foo >{ public: int i; }; > >class bar // this is in file test.C >{ >private: > foo foobar; >public: > baz(foo &fooInstance=foobar); >}; > >Basically, I would like to use the local data member as the argument, I believe that the problem lies here. Use of non-static class members within the default argument expressions of member function is illegal. Section 8.2.6 of the 2.0 Reference Manual clearly states this restriction. // rfg