return ((Soldier*)SvIV(SvRV(obj)))->name; vs return soldier.name;