How do you call the pointer function back to main? I already try "&" didnt work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
For example: I have prototype
void example (int, int, *int,*int,*int,*int);
int main
{
............
example (int, int, &int,&int,&int,&int); // didnt work.
}
void example (int, int, *int,*int,*int,*int);
{
putting code here!
}
You wouldn't pass data types. You'd pass actual arguments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
void exampleFunction( int foo, int *p_foo );
int main( int argc, constchar *argv[] )
{
int a = 0;
exampleFunction( a, &a );
return 0;
}
void exampleFunction( int foo, int *p_foo )
{
std::cout << "Function called\n";
}
What do you mean by call pointer function back to main? When function execution ends, it goes back to the place it got called, and in this case - it would be main function.
PS. "Pointer function"(which I would define, basing on your words, as a function that takes some pointer types as arguments) is not different from "normal" function.
#include <iostream>
void exampleFunction( int &foo );
int main( int argc, constchar *argv[] )
{
int a = 0;
exampleFunction( a );
std::cout << "a is now: " << a << std::endl;
return 0;
}
void exampleFunction( int &foo )
{
foo = 10;
}