Skip to main content
gamedev.net
🔒 Locked

Function array?

Started by Craazer May 19, 2003 at 7:58 AM 4 replies 350+ views
Original Post
Craazer
Craazer
Hi do you think it''s bossible to have one array wich holds same return type funcs but difrend parameter list? And you could use it shometing like this: farray[SPRINTF]("printing using func array\n"); // or what ever
Estor
Estor
What to say... it's killing P)

[edited by - Estor on May 19, 2003 9:49:47 AM]
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen Losers Say Its Over With You Know That It's A Lie The Gods Made Heavy Metal And It's Never Gonna Die"THE GODS MADE HEAVY METAL/by ManOwaR
Craazer
Craazer
quote:
Original post by Anonymous Poster

const int MAX_FUNCTION= 300;
void (fnPointer*)(...);
fnPointer farray[MAX_FUNCTION];

switch(code) {
case SPRINTF:
farray[SPRINTF]("printing using func array\n");
break;
case OTHER:
farray[OTHER](std::ostream(os));
break;
case SOMETHING_OTHER:
farray[SOMETHING_OTHER](true);
break;
case ANOTHER_OTHER:
farray[ANOTHER_OTHER](std::complex(1, 0));
break;
case LAST_OTHER:
farray[LAST_OTHER](std::complex(1, 0), std::complex(9.0, 14));
break;
default:
farray[DEFAULT]("default called",false);
}
etc.


If I saw you do this I''d have to sack you.


Cool! I totally forget "..." operator, thanks AP.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.