View Single Post
  #3   Spotlight this post!  
Unread 17-02-2012, 14:32
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Freebie LV-MaxSonar-EZ1 Code (Sonar Range Finder)

Quote:
Originally Posted by cjlane1138 View Post
First, you cannot put code like that in a header file. Header files are meant to declare variables and functions, not use them. You have to put all of the initialization and actual code in a .cpp file.
Not true. When declaring an object class in a header file, you have an option to include the method bodies in the class definition. We did this throughout all our code. This is because if you separate the definition part in the header file and method bodies in a CPP file, any changes you made to the method interface require you to change two files to match each other. This arrangement is beneficial for releasing libraries without revealing how the methods are implemented (i.e. releasing only the header file without releasing the CPP file). But for our purpose, we don't have this restriction and therefore, it is a lot simpler to include all method bodies in the class definitions in the header files.
__________________
Reply With Quote