Alternate way to find out the Size of Intezer is to find the difference between the &(x) and &(x++) .
(2) Accessing a function Pointer via Structure - Hidden OOPS ?
#include<stdio.h>
void (*funcPtr)();
typedef struct test
{
int x;
char y;
void (*ptr)();
}tstruct;
void show()
{
printf("Demoi \n");
}
void main()
{
tstruct z;
z.x = 100;
z.y = 900;
z.ptr = show;
z.ptr();
}
This programm shows some hidden feature of how OOPs can be implemented using the C.If we assign x as n boolean flag for accessing the function pointed to by the ptr variable , I am sure we can do some OOP stuff here with this code.
(3) What is the structure of the programme in the memory?
More ...to be contniued..!
No comments:
Post a Comment