Advertisement
Felanpro

Functions And How to Include

Nov 3rd, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. //How to make functions work in other "functions".
  2. //1.Either you have to basically like declare that the function is gonna come so the c++ reads it.
  3.  
  4. #include <iostream>
  5. using namespace std; //std is short for standard
  6.  
  7. void printSomething(); //1.Basically declaring that the function is existing and will not give errors.
  8.  
  9. int main()
  10. {
  11. printSomething();
  12. return 0;
  13. }
  14.  
  15. void printSomething();
  16. {
  17. cout << "Text on the screen from function printSomething" << endl; //Here we give the function a value or mostly a function. :)
  18. }
  19.  
  20. /*----------------------------------------------------------------------------------------------------------------*/
  21.  
  22. //2.You can either just put the function Before the other function like this...
  23.  
  24. #include <iostream>
  25. using namespace std;
  26.  
  27. void printSomething();
  28. {
  29. cout << "Solved it!" << endl;
  30. }
  31.  
  32. //And then the function you want to call it in wich is now int main()
  33.  
  34. int main()
  35. {
  36. printSomething(); //To include the function of course :)
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement