Difference between revisions of "User talk:SteveBaker"

From Wikiid
Jump to: navigation, search
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<SCRIPT LANGUAGE="JavaScript">
+
[[File:Bakercoat lowcontrast.png|right]]
  
function convertIt() {
+
So here we have the "header file" called MyClass.h - which contains the declaration of MyClass - and all of the really simple functions (maybe everything under 5 or so lines long is a good rule of thumb). Every ".cpp" file that implements or uses MyClass has to #include this header file. For the very simplest classes, you may not need a ".cpp" file - in which case you can just leave it out.
var centy=0;
+
centy=document.Converter.centigrade.value;
+
document.Converter.faren.value=centy*9/5+32;
+
}
+
</SCRIPT>
+
  
is called when the user moves out of the centigrade input box (onBlur):
+
Each "MyClass.cpp" file must #include (at a minimum) the MyClass.h file so that it can 'see' the class definition at compile time...but it also has to #include the header files for all of the classes that it references (including system headers for classes such as I/O, math, etc).  However, in a complicated program with dozens to hundreds of classes, it can get really hard to remember all of the header files you need - and there is always a half dozen system header files to include (things like 'iostream' that declares std::cout for example).  Hence, a common thing is to make a 'main.h' header that includes all of the other headers - so you only have to remember to stick a '#include "main.h"' at the top of every .cpp file - and you're good to go.
  
<form name="Converter">
+
Then we have MyClass.cpp which contains the implementation of the function "AReallyReallyComplicatedFunction" - and we have "main.cpp" that contains our main program.  Usually, this file is named after the program itself rather than "main" - so if this is MyFirstVideoGame then we'd probably call the files "MyFirstVideoGame.h" and "MyFirstVideoGame.cpp".
Enter the Centigrade Temperature:
+
<input type=text name="centigrade" size=10 onblur="convertIt()">
+
 
+
Press "tab" to see the Farenheit Temperature:<input type=text name="faren" size=10> </form>
+
 
+
<center>HELLO!</center>
+

Latest revision as of 08:40, 23 October 2010

Bakercoat lowcontrast.png

So here we have the "header file" called MyClass.h - which contains the declaration of MyClass - and all of the really simple functions (maybe everything under 5 or so lines long is a good rule of thumb). Every ".cpp" file that implements or uses MyClass has to #include this header file. For the very simplest classes, you may not need a ".cpp" file - in which case you can just leave it out.

Each "MyClass.cpp" file must #include (at a minimum) the MyClass.h file so that it can 'see' the class definition at compile time...but it also has to #include the header files for all of the classes that it references (including system headers for classes such as I/O, math, etc). However, in a complicated program with dozens to hundreds of classes, it can get really hard to remember all of the header files you need - and there is always a half dozen system header files to include (things like 'iostream' that declares std::cout for example). Hence, a common thing is to make a 'main.h' header that includes all of the other headers - so you only have to remember to stick a '#include "main.h"' at the top of every .cpp file - and you're good to go.

Then we have MyClass.cpp which contains the implementation of the function "AReallyReallyComplicatedFunction" - and we have "main.cpp" that contains our main program. Usually, this file is named after the program itself rather than "main" - so if this is MyFirstVideoGame then we'd probably call the files "MyFirstVideoGame.h" and "MyFirstVideoGame.cpp".