S
subramanian100in
Can a structure contain function pointers as members ?
If so, where is it useful ?
If so, where is it useful ?
Can a structure contain function pointers as members ?
Yes.
If so, where is it useful ?
ya we can do this .like
struct abc
{
int a;
char name[10];
int *(functionptr)(int,int);
Can a structure contain function pointers as members ?
If so, where is it useful ?
The following article may give some ideas. It is not perfect and may
be improved but it shows one way to program polymorphically in C:
http://www.codeproject.com/cpp/PolymorphismC.asp
Flash said:.... snip ...
It certainly needs some work. It uses a macro name which is an
underscore followed by a capital in the header, and such names
are reserved for the implementation. It uses the form
type *ptr = (type *)malloc(sizeof(type));
instead of the simpler and more robust
type *ptr = (type *)malloc(sizeof(type));
Flash Gordon said:Roland Pibinger wrote, On 22/02/07 20:18:
It certainly needs some work. It uses a macro name which is an
underscore followed by a capital in the header, and such names are
reserved for the implementation. It uses the form
type *ptr = (type *)malloc(sizeof(type));
instead of the simpler and more robust
type *ptr = (type *)malloc(sizeof(type));
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.