fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Car
  5. {
  6. public:
  7. int speed;
  8. int colour;
  9. };
  10.  
  11. int main()
  12. {
  13. Car a;
  14. a.speed=1;
  15. a.colour=2;
  16.  
  17. int Car::*p;
  18. p= &a.speed;
  19. cout<<*p;
  20.  
  21. return 0;
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:18:11: error: cannot convert ‘int*’ to ‘int Car::*’ in assignment
     p= &a.speed;
           ^~~~~
prog.cpp:19:12: error: invalid use of unary ‘*’ on pointer to member
     cout<<*p;
            ^
stdout
Standard output is empty