Declaring struct attribute with different type
<p>I have a struct that contain an attribute that can take many types,
I want ask about the most appropriate way to declare this attribute.</p>

<p>Example:</p>

<pre><code>struct 
{
void* pShape; //poiter to the shape that will be casted on *tCircle or *tRectangle
int type;//type of the shape
int h;
int l;
}tImage;

struct{
int size;
int r;
HANDLE calcul;
}tCircle

struct{
int size;
int x;
int y;
HANDLE calcul;
}tRectangle;
</code></pre>

<p>As you see here i'am using void* to declare a pointer to the shape and use type attribute to guess the type of the shape.</p>

<p>this is my function for the calcuation of the size of the shape in an image </p>

<pre><code>int Image_Get_ShapeSize(tImage Im)
{
 switch (Im.type)
 {
 case CIRCLE:
 ((tCircle*)(Im.shape))-&gt;calcul();
 break;

 case RECTANGLE:
 ((tRectangle*)(Im.shape))-&gt;calcul();
 break;

 default:
 break;
}
}
</code></pre>

<p>what do you think about this is it a good method ?</p>