fork(1) download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. /*
  9.  *
  10.  */
  11. class apple{
  12. private:
  13. int a,b,c,d;
  14. public:
  15. int foo(){
  16. return a+b+c+d;
  17. }
  18. };
  19. class ball{
  20. private:
  21. map<apple,string> mp;
  22. public:
  23. void foo2(){
  24. for(map<apple,string>::iterator it = mp.begin();it!=mp.end();++it){
  25. cout<<it->first.foo()<<endl;
  26. }
  27. }
  28.  
  29. }
  30. int main(int argc, char** argv) {
  31.  
  32. return 0;
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:29:1: error: expected ‘;’ after class definition
 }
 ^
prog.cpp: In member function ‘void ball::foo2()’:
prog.cpp:25:33: error: passing ‘const apple’ as ‘this’ argument discards qualifiers [-fpermissive]
             cout<<it->first.foo()<<endl;
                                 ^
prog.cpp:15:9: note:   in call to ‘int apple::foo()’
     int foo(){
         ^~~
stdout
Standard output is empty