fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Cos {
  5. public:
  6. int *x;
  7. int y;
  8. Cos(int *x, int y) : x(x), y(y) {}
  9. };
  10.  
  11. ostream& operator<<(ostream &os, const Cos &c){
  12. os << "*c.x=" << *(c.x) << ", c.x=" << c.x;
  13. return os;
  14. }
  15.  
  16. int main(){
  17. int p = 56;
  18. Cos c(&p,4);
  19. cout << "&p=" << &p << endl;
  20. cout << "*c.x " << *c.x << endl;
  21. cout << "c.x " << c.x << endl;
  22. cout << "c " << c << endl;
  23.  
  24. int a = 100;
  25. int *w = &a;
  26. cout << "w " << *w << endl;
  27. return 0;
  28. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
&p=0xbfed55c4
*c.x 56
c.x 0xbfed55c4
c *c.x=56, c.x=0xbfed55c4
w 100