First of all, standard C, as a language, does not even have
such a thing as a class. The class was introduced in C++, which was originally called C with Classes; thus, there is no class in C. There does exist the struct
in C and RobotC but this is not the same thing as a in C++, C#, Java, etc. The C struct is simply a wrapper for a collection of basic data types or other structs. C structs can not contain functions and there is no such thing as inheritance (that I know of), overloading, etc. C structs also don't support static or constant members, or at least RobotC structs don't
Structs can be created using the typedef
The name for the struct is placed at the end rather than the beginning of the definition. In this regard RobotC dosen't really follow the rules.
For those unfamiliar with object oriented programming, here is how you could use a struct.
A struct is essentially your own data type; you create an instance of it just like you create a standard variable,
Now RobotC does seem to define the class
keyword, but I can't get it to work even using the typedef
keyword. I'm not sure what to make of it as C isn't even supposed to define the class
keyword. I'd stay away from it either way as you can't use the benefits of object orientation in C nor does the NXT support dynamic memory managagement, i.e. pointers; additionally RobotC doesn't seem to completely follow the rules of C for creating structs. Unfortunately C structs, in my C++ biased opinion, aren't very useful so it's ok to not use them, but if you want to knock yourself out.