structure assignment, why you would want to do it

Stan Brown, Oak Road Systems browns at iccgcc.decnet.ab.com
Mon Aug 27 03:59:31 AEST 1990


In article <1096.26d52ea3 at desire.wright.edu>, demon at desire.wright.edu writes:
 
> 	Thanx!  Everyone wondered why I asked it.  If you are doing
> transformations/similar math stuff or (like I'm doing) vehicle position updates
> for a military simulation, you'd like to be able to say
> 
> pres_location += current_move;
[For those who may not be in on the beginning of the thread, pres_location
and current_move are structure variables, either of the same type or with
matching members.]
> 
> to update the vehicles location.  I could go through and assign the x,y,z
> locations individually, but it would be nice (and cleaner looking) to do a
> structure assignment.
>         It was intended that the assignement/operator would only be performed
> on like structure elements, and only on elements defined for the operater(s).
> 
>         Hmm, the next C standard is how many years away? :)

But you can do this noww, can't you?  Isn't this the sort of "operator
overloading" that is a strength of C++?  I can't give specifics, because
I'm just getting into C++, but seems to me like the problem you're trying
to solve would go better in C++ than C.

Stan Brown, Oak Road Systems, Cleveland, Ohio, U.S.A.         (216) 371-0043
The opinions expressed are mine. Mine alone!  Nobody else is responsible for
them or even endorses them--except my cat Dexter, and he signed the power of
attorney only under my threat to cut off his Cat Chow!



More information about the Comp.lang.c mailing list