Advertisement
adelinedel

Journal 7C Poiinters to Functions

Apr 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /*Adeline Delgleize
  2. Student ID 0515277
  3. Journal 7C
  4. Pointers to Functions
  5. April 29, 2017*/
  6.  
  7. #include<iostream>
  8.  
  9. using namespace std;
  10.  
  11. void one();
  12. void two();
  13. void three();
  14. void four();
  15.  
  16. int main()
  17. {
  18.  
  19. void(*func[4])();
  20.  
  21. func[0] = one;
  22. func[1] = two;
  23. func[2] = three;
  24. func[3] = four;
  25.  
  26. for (int i = 0; 1 < 4; i++) //for loop iterates through the four functions via pointer
  27. func[i]();
  28.  
  29.  
  30.  
  31. return 0;
  32. }
  33.  
  34.  
  35. void one()
  36. {
  37. cout << "Hello from One. " << endl;
  38.  
  39. }
  40.  
  41. void two()
  42. {
  43. cout << "Hello from Two. " << endl;
  44.  
  45. }
  46.  
  47. void three()
  48. {
  49. cout << "Hello from Three. " << endl;
  50.  
  51. }
  52.  
  53. void four()
  54. {
  55. cout << "Hello from Four. " << endl;
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement