I have structure(A) and it takes another structure(B) as member.
Now i want structure C as member of A instead of B.
Both B and C are of same type
typedef struct
{
int a;
B b;
}A
typedef struct
{
int a;
}B
typedef struct
{
int a;
}C
How can i assign struct C as member instead of B. How to do typecasting
Please help
Without knowing why you want to do this, its hard to recommend a strategy. Here are a few options though.
Option 1: Use Templates. (C++ only)
Option 2: Make struct A contain a void* (not recommended, you will lose all type safety). (Both C/C++)