fork download
  1. int main(int argc, char *argv[])
  2. {
  3. MixedExpression res;
  4. MixedExpression op1;
  5. MixedExpression op2;
  6. char symbol;
  7. long x,y;
  8. ifstream in;
  9. ofstream out;
  10.  
  11. if(argc > 1)
  12. {
  13. in.open(argv[1]);
  14. if(in)
  15. {
  16. out.open(argv[2]);
  17. while(!in.eof())
  18. {
  19. res.ReadMixedExp(in);
  20. switch(symbol)
  21. {
  22. case '+': res = op1.add(op2); // Get the sum.
  23. break;
  24. case '-': res = op1.subtract(op2); // Get the difference.
  25. break;
  26. case '*': res = op1.multiply(op2); // Get the product.
  27. break;
  28. case '/': res = op1.divide(op2); // Get the quotient.
  29. break;
  30. }
  31. res.printData(out);
  32. }
  33. }
  34. // Close the input file.
  35. in.close();
  36. // Close the output file.
  37. out.close();
  38. }
  39. return 0;
  40. }
  41.  
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:3:2: error: ‘MixedExpression’ was not declared in this scope
  MixedExpression res;
  ^
prog.cpp:3:18: error: expected ‘;’ before ‘res’
  MixedExpression res;
                  ^
prog.cpp:4:18: error: expected ‘;’ before ‘op1’
  MixedExpression op1;
                  ^
prog.cpp:5:18: error: expected ‘;’ before ‘op2’
  MixedExpression op2;
                  ^
prog.cpp:8:2: error: ‘ifstream’ was not declared in this scope
  ifstream in;
  ^
prog.cpp:8:11: error: expected ‘;’ before ‘in’
  ifstream in;
           ^
prog.cpp:9:2: error: ‘ofstream’ was not declared in this scope
  ofstream out;
  ^
prog.cpp:9:11: error: expected ‘;’ before ‘out’
  ofstream out;
           ^
prog.cpp:13:3: error: ‘in’ was not declared in this scope
   in.open(argv[1]);
   ^
prog.cpp:16:4: error: ‘out’ was not declared in this scope
    out.open(argv[2]);
    ^
prog.cpp:19:5: error: ‘res’ was not declared in this scope
     res.ReadMixedExp(in);
     ^
prog.cpp:22:22: error: ‘op1’ was not declared in this scope
      case '+': res = op1.add(op2); // Get the sum.
                      ^
prog.cpp:22:30: error: ‘op2’ was not declared in this scope
      case '+': res = op1.add(op2); // Get the sum.
                              ^
prog.cpp:37:3: error: ‘out’ was not declared in this scope
   out.close();
   ^
prog.cpp:7:7: warning: unused variable ‘x’ [-Wunused-variable]
  long x,y;
       ^
prog.cpp:7:9: warning: unused variable ‘y’ [-Wunused-variable]
  long x,y;
         ^
stdout
Standard output is empty