And I recommend Manu12x to think how many legs a robot has, based on your code and with the code I give you it only has one leg...
I understand you have only one texture but you still need 2 positions or rects to draw them.
So you have the positions of legs outside the object? Or you updated the class code to have two legs? Just curious.
This is nonsense in any language I know (quite a few )
struct TRobot{ int Value1; struct { int Rect1, Rect2; void AssignValue(long x, long y, long w, long h) { // assign Rect1 and Rect2 as needed... } } Head, Body, Foot, Knee, Leg; TRobot(); ~TRobot();};