To: djgpp AT delorie DOT com Message-Id: Mime-Version: 1.0 Organization: Moscow State University Branch in Ulianovsk, MMF From: akondra AT mmf DOT univ DOT simbirsk DOT su (A.V. Kondratiev) Date: Tue, 3 Jun 97 10:47:49 +0400 Subject: Static member functions in constructor Lines: 34 Precedence: bulk I encountered a strange g++ behavior. I tried to pass a static member function as a default parameter of constructor. Here is an example: typedef void ( *ft )(); class A { public: static void F1(); const ft pf; A(ft f=F1):pf(f){} // (1) // A(ft f=0):pf(f ? f:F1){} // (2) }; void A::F1() {/*something*/} int main() { A a; return 0; } In case (1) the compiler reports that F1 is not defined. GCC doc tells that `g++' reports as undefined symbols any static data members that lack definitions. But I provided definition for F1! I tried to work around this strange behavior as in case (2). It works but may anybody suggest a better solution? Of course, the easiest way is to declare F1 as a normal outer function, not as a static member. But, in my opinion, it is not a good solution in object-oriented programming. Aleksey.