Game Programming




 
game programming
Game Programming :: Programming :: General Programming :: Code Examples :: [C++]Basic functions - View Topic
Topic Rating: *****
Printable View
Andy
Administrator
*****

Posts: 40
Status: Offline
Gender: Male
Joined:  
pm

Reputation: 0%

[C++]Basic functions (11th Jan 08 at 1:42am UTC)
this is just a small block of code showing you how a basic function is set up

Code:
 
  1. //include iostream file to be able to use
  2. //cout and cin
  3. #include <iostream>
  4.  
  5. //define Hello(); function
  6. void Hello();
  7.  
  8. //declare Hello(); function
  9. void Hello()
  10. {  
  11.     //print text hello world
  12.     std::cout << "Hello world ";
  13.  
  14. }
  15.  
  16. //start main
  17. int main()
  18. {
  19.  
  20.    Hello();//call Hello(); function
  21.  
  22.    std::cin.get();//wait for user to press enter or return
  23.   
  24.    return 0; //return 0 to indicate know problems found
  25.  
  26. }//end of main
  27.  
 


it is that simple there are many things you can do with functions such as returning values function pointers and more
 Printable View

All times are GMT+0 :: The current time is 7:57am
Page generated in 0.3191 seconds
Purchase Ad-Free Credits
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums