fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class a {
  5. public:
  6. int x,y,z;
  7. public:
  8. void set();
  9. void show();
  10. };
  11. void a::set()
  12. {
  13. cout<<"Enter x and y";
  14. cin>>x>>y;
  15. z=x+y;
  16. }
  17. void a::show()
  18. {
  19. cout<<"x"<<x<<endl;
  20. cout<<"y"<<y<<endl;
  21. cout<<"z"<<z<<endl;
  22. }
  23. void main()
  24. {
  25. a a1;
  26. a1.set();
  27. a1.show();
  28. getch();
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
2
compilation info
prog.cpp:23:11: error: ‘::main’ must return ‘int’
 void main()
           ^
prog.cpp: In function ‘int main()’:
prog.cpp:28:8: error: ‘getch’ was not declared in this scope
  getch();
        ^
stdout
Standard output is empty