Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Adeline Delgleize
- Student ID 0515277
- Journal 7C
- Pointers to Functions
- April 29, 2017*/
- #include<iostream>
- using namespace std;
- void one();
- void two();
- void three();
- void four();
- int main()
- {
- void(*func[4])();
- func[0] = one;
- func[1] = two;
- func[2] = three;
- func[3] = four;
- for (int i = 0; 1 < 4; i++) //for loop iterates through the four functions via pointer
- func[i]();
- return 0;
- }
- void one()
- {
- cout << "Hello from One. " << endl;
- }
- void two()
- {
- cout << "Hello from Two. " << endl;
- }
- void three()
- {
- cout << "Hello from Three. " << endl;
- }
- void four()
- {
- cout << "Hello from Four. " << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement