Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!bellcore!salt!stanm From: stanm@thumper.bellcore.com (Stan Moyer) Newsgroups: comp.lang.c++ Subject: constructor as default argument Message-ID: <441@salt.bellcore.com> Date: 12 Jun 91 13:39:31 GMT Sender: news@salt.bellcore.com Lines: 39 I am having trouble using a constructor as a default argument for a function. I am using cfront V2.1 Here is a sample of what I have tried and the resulting error messages. class X { public: X(int); }; 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); }; functions f & h give me the following error message: "sorry, not implemented: constructor needed for argument initializer" function g gives me the following error message: "sorry, not implemented: constructor as default argument" I really didn't expect f to work, but I thought g & h would be valid. Is this not allowed in C++? Can you only use fundamental data types as default arguments? Does this not work because a default argument must be a compile-time constant? I could not find anything about it in the ARM. Any help would be appreciated. Thanks in advance, Stan Moyer ; Bellcore, MRE-2A219; 445 South Street, Morristown, NJ 07962-1910 voice: +201.829.4923; fax: +201.984.2283