View Single Post
  #3   Spotlight this post!  
Unread 15-05-2009, 13:43
Chris27's Avatar
Chris27 Chris27 is offline
Registered User
AKA: Chris Freeman
FRC #1625 (Winnovation)
Team Role: Alumni
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Mountain View
Posts: 196
Chris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant futureChris27 has a brilliant future
Re: **FIRST EMAIL**/Java and Orbit Balls

Quote:
Originally Posted by The Lucas View Post
Pointer arithmetic. It can be useful if used properly. However, I wouldn't encourage students new to C++ to use pointer arithmetic on the robot, unless of course, you want them to experience the frustration of the dreaded "Seg Fault".
Code:
char *ptr = malloc(SIZE);
ptr + i is equivalent to &ptr[i]. Both cases boil down to just a load effective address instruction. Besides the obvious that Java hides the virtual address of all values in the symbol table, I don't see how you are missing anything by not being able to explicitly use pointer arithmetic. The point of pointer arithmetic is to compute the address of an element in an array. the "[]" operator retrieves that element and many people find this interface more intuitive. There is no performance advantage of using pointer arithmetic and there is nothing you can't do with the "[]" that you can do with pointer arithmetic (as the "[]" operator just encapsulates pointer arithmetic).