Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!bionet!ames!ucsd!orion.cf.uci.edu!uci-ics!siam.ics.uci.edu!schmidt From: schmidt@siam.ics.uci.edu (Doug Schmidt) Newsgroups: comp.lang.c++ Subject: Calling constructors explicitly Message-ID: <8102@paris.ics.uci.edu> Date: 23 Feb 89 21:00:56 GMT Sender: news@paris.ics.uci.edu Reply-To: Doug Schmidt Organization: University of California at Irvine: ICS Dept. Lines: 42 In the following short C++ program the constructor for class foo is explicitly called as a member function. However, when compiling this with cfront 1.2.1 the translator complains that: ---------------------------------------- CC test.c: "test.c", line 14: error: foo is undefined 1 error ---------------------------------------- Apparently, cfront 2.0 also exhibits the same behavior. Would someone please tell me whether this is a bug or a feature, i.e., is it part of the language definition that constructors must not be called explicitly? thank you, Doug Schmidt ---------------------------------------- int printf (char *, ...); class foo { public: static foo () { printf ("hello world\n"); } }; main () { foo bar; bar.foo (); } ---------------------------------------- -- schmidt@ics.uci.edu (ARPA) | Per me si va nella citta' dolente. office: (714) 856-4043 | Per me si va nell'eterno dolore. | Per me si va tra la perduta gente. | Lasciate ogni speranza o voi ch'entrate.