Created
March 17, 2014 01:25
-
-
Save nightpool/9592361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
// So this is my main function | |
// it gets called automatically, but otherwise its no different then any other function | |
int number_of_tates = 0; // I take inspiration from my enviroment ;) | |
number_of_tates = work_on_song(number_of_tates); // Now I'm going to call my function, which I define down below. | |
// It takes an integer, the old amount, and returns an integer (the new amount). | |
// After calling the function, I assign it to the variable "number_of_tates", | |
// overwriting the old value. | |
cout << number_of_tates << end; // prints '3' | |
number_of_tates = work_on_song(number_of_tates); | |
number_of_tates = work_on_song(number_of_tates); | |
} | |
int work_on_song(int n) { | |
return n + 3; | |
} | |
// To be exceedingly pedantic, this code won't compile as is. Because of historical reasons, | |
// C++ functions need to be declared above where you want to use them. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment