Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bellcore!salt!stanm From: stanm@thumper.bellcore.com (Stan Moyer) Newsgroups: comp.lang.c++ Subject: Re: constructor as default argument Message-ID: <443@salt.bellcore.com> Date: 12 Jun 91 18:01:23 GMT Sender: news@salt.bellcore.com Lines: 53 In regards to my earlier posting, I've learned the following: This piece of code: #include class X { public: X(int i) { cout << "X(int): " << i << "\n"; } }; const int DEF_X = 0; class Y { public: Y() {} void f(X x=0) {} void g(X x=X(0)) {} void h(X x=DEF_X) {} }; main () { Y y; y.f(); y.g(); y.h(); } compiles and produces the following output with g++: X(int): 0 X(int): 0 X(int): 0 However, when I try to compile with cfront, I get the following output: line 13: sorry, not implemented: constructor needed for argument initializer line 14: sorry, not implemented: constructor as default argument line 15: sorry, not implemented: constructor needed for argument initializer I have learned that "sorry, not implemented" does not mean that there is an error, but rather "this is probably valid C++, but we haven't implemented it in the compiler." Hopefully a future version (3.0?) of cfront will implement this, but until then I'll have to work around it. Thanks to Martin Hitz and Brian Kennedy for their responses. Stan Moyer ; Bellcore, MRE-2A219; 445 South Street, Morristown, NJ 07962-1910 voice: +201.829.4923; fax: +201.984.2283