Object oriented programming in C
braner
braner at batcomputer.tn.cornell.edu
Fri Nov 14 05:15:50 AEST 1986
[]
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
More information about the Comp.lang.c
mailing list