monolithed (2016-01-03T23:07:57.000Z)
monolithed at gmail.com (2016-01-03T23:30:30.818Z)
C++: ```cpp #include <iostream> class A { public: A () { this->x = 1; } int call () { return this->x; } int x; }; class B : public A { public: B() : A () { this->x = 2; } int x; }; int main () { B b; std::cout << b.call(); // 1 return 0; } ``` JavaScript: ```js class A { constructor () { this.x = 1; } call () { return this.x; } } class B extends A { constructor () { super(); this.x = 2; } } let b = new B(); b.call(); // 2 ``` ~~Why we have different behavior?!~~ I know that ECMAScript classes are syntactical sugar, but this behavior is unexpected for many people...
monolithed at gmail.com (2016-01-03T23:30:03.880Z)
C++: ```c++ #include <iostream> class A { public: A () { this->x = 1; } int call () { return this->x; } int x; }; class B : public A { public: B() : A () { this->x = 2; } int x; }; int main () { B b; std::cout << b.call(); // 1 return 0; } ``` JavaScript: ```js class A { constructor () { this.x = 1; } call () { return this.x; } } class B extends A { constructor () { super(); this.x = 2; } } let b = new B(); b.call(); // 2 ``` ~~Why we have different behavior?!~~ I know that ECMAScript classes are syntactical sugar, but this behavior is unexpected for many people...