fork(1) download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3.  
  4. class T {
  5. public:
  6. template<typename Func>
  7. double execute(Func expression) {
  8. return expression();
  9. }
  10. };
  11.  
  12. int main() {
  13. T t;
  14. int a = 0, b = 1;
  15. double result = t.execute([&a,&b]() -> double {return 3 * a + 5 * b;});
  16. cout << result << endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
5