fork download
  1. // function_pointer_resolution.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. extern void show_int( int );
  5.  
  6. extern "C" typedef int binary_int_func( int, int );
  7.  
  8. extern "C" binary_int_func sum;
  9. extern "C" binary_int_func* const sum_ptr = sum;
  10.  
  11. inline int call( binary_int_func* binary, int a, int b ) { return (*binary)(a, b); }
  12.  
  13. template< binary_int_func* binary >
  14. inline int callt( int a, int b ) { return (*binary)(a, b); }
  15.  
  16. int main( void )
  17. {
  18. show_int( sum(1, 2) );
  19. show_int( call(&sum, 3, 4) );
  20. show_int( callt<&sum>(5, 6) );
  21. show_int( (*sum_ptr)(1, 7) );
  22. show_int( call(sum_ptr, 3, 8) );
  23. show_int( callt<sum_ptr>(5, 9) );
  24. return 0;
  25. }
  26.  
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/home/D7cepa/ccyU5DLd.o: In function `main':
prog.cpp:(.text.startup+0x19): undefined reference to `sum'
prog.cpp:(.text.startup+0x21): undefined reference to `show_int(int)'
prog.cpp:(.text.startup+0x35): undefined reference to `sum'
prog.cpp:(.text.startup+0x3d): undefined reference to `show_int(int)'
prog.cpp:(.text.startup+0x51): undefined reference to `sum'
prog.cpp:(.text.startup+0x59): undefined reference to `show_int(int)'
prog.cpp:(.text.startup+0x6d): undefined reference to `sum'
prog.cpp:(.text.startup+0x75): undefined reference to `show_int(int)'
prog.cpp:(.text.startup+0x89): undefined reference to `sum'
prog.cpp:(.text.startup+0x91): undefined reference to `show_int(int)'
prog.cpp:(.text.startup+0xa5): undefined reference to `sum'
prog.cpp:(.text.startup+0xad): undefined reference to `show_int(int)'
/home/D7cepa/ccyU5DLd.o:(.rodata+0x0): undefined reference to `sum'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty