Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. #include "Main.h"
  5. #include "FileChannel.h"
  6.  
  7. typedef int (*TCHAN_Getc)(int Port);
  8.  
  9.  
  10. struct TChanApi {
  11.    TCHAN_Getc onCHAN_Getc;
  12. };
  13.  
  14. std::function<int(int)> global_func;
  15.  
  16. int callback(int Port) {
  17.     return global_func(Port);
  18. }
  19.  
  20. int main (int argc, char *argv[])
  21. {
  22.     FileChannel channel;
  23.    
  24.     TChanApi chanApi;
  25.    
  26.     global_func = [&](int Port) {
  27.         return channel.getChar(Port);
  28.     };
  29.  
  30.     chanApi.onCHAN_Getc= callback;
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement