Re: OOP in C!

From: Prashanth Ellina (prashanthellina_at_hotpop.com)
Date: 06/07/04


Date: 7 Jun 2004 14:24:36 -0700


"Mike Wahler" <mkwahler@mkwahler.net> wrote in message news:<VNOvc.20736$Tn6.8282@newsread1.news.pas.earthlink.net>...
 
> #include <stdio.h>
>
> struct S
> {
> int member;
> void (*fp)(struct S *);
> };
>
> void func(struct S *param)
> {
> printf("%d\n", param->member);
> }
>
> int main()
> {
> struct S object = {42, func};
> func(&object); /* prints 42 */

shouldn't the above line be,
object.fp(&object);
?

> return 0;
> }
>
> -Mike
>
>
>
> >
> > Thanks in advance,
> > Prashanth Ellina



Relevant Pages

  • "Default construction" of NON-built-in types?
    ... The struct had an int member which I expected to be ... home dot pacbell dot net slant earnur slant ...
    (comp.lang.cpp)
  • Re: Forward Declarations
    ... Frederick Gotham writes: ... struct something { ... In the spirit of keeping things mathematical, ...
    (comp.lang.c)
  • Re: Forward Declarations
    ... struct something { ... In the spirit of keeping things mathematical, maybe "should create zero ... Frederick Gotham ...
    (comp.lang.c)
  • Re: Forward Declarations
    ... because a structure definition all by itself would yield ... an unnamed instance of that structure right at that location. ... This would deposit an unnamed "struct something" right there in the ...
    (comp.lang.c)