fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class test {
  5. private:
  6. int a;
  7. int b;
  8.  
  9. public:
  10. test();
  11. void foo() const;
  12. };
  13.  
  14. test::test() {
  15. int a = 3;
  16. int b = 4;
  17.  
  18. cout << "a: " << a << ", b: " << b << endl;
  19. }
  20.  
  21. void test::foo() const {
  22. cout << "a: " << a << ", b: " << b << endl;
  23. }
  24.  
  25.  
  26. int main() {
  27. test t1;
  28. t1.foo();
  29.  
  30. cout << endl;
  31.  
  32. const test t2;
  33. t2.foo();
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
a: 3, b: 4
a: 134515248, b: 0

a: 3, b: 4
a: 134515259, b: -1219039232