fork download
  1. #include <stdio.h>
  2. struct A {
  3. int c;
  4. int x(int a, int b);
  5. static int y(int a, int b);
  6. A(int x) : c(x) {}
  7. };
  8. int A::x(int a, int b) { return a * b * this->c; }
  9. int A::y(int a, int b) { return a * b /* * this->c */ ; } // 'this' is unavailable for static member function
  10. int main(void) {
  11. A a(5);
  12. printf("%d", a.x(2, 3));
  13. printf("%d", a.y(2, 3)); // *** why can we call this way ? ***
  14. // printf("%d", A::x(2, 3)); // cannot call member function
  15. printf("%d", A::y(2, 3));
  16. return 0;
  17. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
3066