Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!cornell!batcomputer!braner From: braner@batcomputer.tn.cornell.edu (braner) Newsgroups: comp.lang.c,comp.lang.c++,comp.sys.atari.st Subject: Re: Object oriented programming in C Message-ID: <1497@batcomputer.tn.cornell.edu> Date: Thu, 13-Nov-86 14:15:50 EST Article-I.D.: batcompu.1497 Posted: Thu Nov 13 14:15:50 1986 Date-Received: Fri, 14-Nov-86 05:59:06 EST Reply-To: braner@batcomputer.UUCP (braner) Distribution: world Organization: Theory Center, Cornell University, Ithaca NY Lines: 25 Summary: a little bug Xref: mnetor comp.lang.c:39 comp.lang.c++:10 comp.sys.atari.st:37 [] A while ago I posted a method to do object oriented programming in C. At the heart of the method is a function that is called every time a method is being looked up. This function, called FindMethod, returns the address of the method - a pointer to a function. Now how do you declare a function of that type? A variable of type pointer to a function which in turn returns an int is declared as: int (*foo)(); and in my posting I declared FindMethod as: int (*FindMethod())(token,obp); Turns out that the correct syntax is: int (*FindMethod(token,obp))(); What is surprising is that the compiler I used (Megamax C on the Atari ST) did not complain, and went on to produce code that did just what I intended! But other compilers complained. Thanks to Don Howes that notified me of the problem. - Moshe Braner