This code was published at http://accu.org/index.php/cvujournal , July 2013 issue. I could not understand the result, any explanation would be helphful
#include <iostream> int x; struct i { i() { x = 0; std::cout << "--C1\n"; } i(int i) { x = i; std::cout << "--C2\n"; } }; class l { public: l(int i) : x(i) {} void load() { i(x); } private: int x; }; int main() { ll(42); l.load(); std::cout << x << std::endl; }
Output:
--C1 0
I expected:
--C2 42
Any explanation?
c ++ struct
Maverick
source share