Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions as function parameter?

Status
Not open for further replies.

surrealandlost

Programmer
Apr 12, 2002
3
US
Is it at all possible in a standard console program to pass a function as a parameter?

Example:
int test( int x, int y ) {
return (x + y);
}
int foo( int z, function blah ) {
return blah( z, 1 )
}
int main() {
cout << foo( 1, test ) << endl;
// will print 2
return 0;
}
 
Yes. But you may want to use a * to a function instead. Look up Adapters in the Documentation.

William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top