Skip to content

Instantly share code, notes, and snippets.

@kana
Forked from Sixeight/gist:127091
Created June 10, 2009 13:44
Show Gist options
  • Save kana/127218 to your computer and use it in GitHub Desktop.
Save kana/127218 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef struct Greeter
{
struct Greeter (*hello)(const char*);
} Greeter;
Greeter hello(const char *name);
Greeter
initialize()
{
Greeter res;
res.hello = hello;
return res;
}
Greeter
hello(const char *name)
{
printf("hello, %s.\n", name);
return initialize();
}
int
main(int argc, char *argv[])
{
Greeter me = initialize();
me.hello("yaotti").
hello("satzz").
hello("hmsk");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment