fork(1) download
  1. #include <vector>
  2. #include <map>
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. struct callable {
  8. virtual void operator()(vector<string> args) = 0;
  9. }
  10.  
  11. std::map<std::string, callable> commands =
  12. {
  13. { "cd", struct : callable
  14. {
  15. operator()(vector<string> args) {
  16. out << "cd called with args" << endl;
  17. for (auto i = args.begin(); args.end() != i; ++i) out << *i << endl;
  18. }
  19. }
  20. }
  21. }
  22.  
  23. int main() {
  24. vector<string> args = {"hello", "world"};
  25. commands["cd"](args);
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:33: error: invalid declarator before 'commands'
 std::map<std::string, callable> commands =
                                 ^
stdout
Standard output is empty