Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!abvax!iccgcc!browns From: browns@iccgcc.decnet.ab.com (Stan Brown, Oak Road Systems) Newsgroups: comp.lang.c Subject: Re: structure assignment, why you would want to do it Message-ID: <627.26d7c7b3@iccgcc.decnet.ab.com> Date: 26 Aug 90 17:59:31 GMT References: <1081.26d26274@desire.wright.edu> <352@saxony.pa.reuter.COM> <3615@goanna.cs.rmit.oz.au> <1096.26d52ea3@desire.wright.edu> Lines: 28 In article <1096.26d52ea3@desire.wright.edu>, demon@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!