|
Page 1 of 1
|
[ 5 posts ] |
|
Operator overloading for a struct
Author |
Message |
lemiant
Rookie
Joined: Fri Nov 22, 2013 5:40 pm Posts: 2
|
 Operator overloading for a struct
Is it possible to do operator overloading in RobotC? For example we have a struct: And we would like to be able to run: And have all the x,y,z values copied over. Is this possible in RobotC? Thanks in advance, - Alex
|
Fri Nov 22, 2013 5:47 pm |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 Re: Operator overloading for a struct
No, I don't think this is possible in RobotC (or ANSI C, even).
_________________FTC Team 6424, the 'Oly Cow - Chief programmer. FRC Team 4450, Olympia Robotics Federation (ORF). and also quadrotors. Quadrotors!
|
Fri Nov 22, 2013 6:52 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Operator overloading for a struct
 |  |  |  | lemiant wrote: Is it possible to do operator overloading in RobotC? For example we have a struct: And we would like to be able to run: And have all the x,y,z values copied over. Is this possible in RobotC? Thanks in advance, - Alex |  |  |  |  |
That's not operator overloading. That's just structure assignment. This should be allowed. Since you already have the code written, why can't you just compile the code and check it out. To verify if it indeed works, add some nxtDisplayText statements in the code such as:
|
Sat Nov 23, 2013 8:17 am |
|
 |
lemiant
Rookie
Joined: Fri Nov 22, 2013 5:40 pm Posts: 2
|
 Re: Operator overloading for a struct
Good idea with the testing. It seems that structs can be passed as parameters to functions, but you cannot do a=b as I was hoping. Does that make sense?
|
Sat Nov 23, 2013 3:08 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Operator overloading for a struct
Hmm, you are right. It looks like structure assignment doesn't work. Then try this:
|
Sat Nov 23, 2013 4:51 pm |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|