fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class MyClass {
  6. public:
  7. static const int A = 2;
  8. const int B = 4;
  9. };
  10.  
  11. int main() {
  12. MyClass obj;
  13. /* This */
  14. cout << obj.A << endl;
  15. /* Would be the same as this */
  16. cout << MyClass::A << endl;
  17. /* B only belongs to obj */
  18. cout << obj.B << endl;
  19. /* And this is illegal */
  20. //cout << MyClass::B << endl;
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
2
2
4