Open iarede opened 2 years ago
The default constructor initializes only the data[0] element:
data[0]
https://github.com/PacktPublishing/The-Modern-Cpp-Challenge/blob/a3eb81b153758c90f1de7a82792892814e69839e/Chapter02/problem_15/main.cpp#L10 \ For example, if you change the code as follows:
constexpr ipv4() :data{ {42} } {}
then
ipv4 ip; std::cout << ip << std::endl;
produces:
42.0.0.0
\ Possible fix:
constexpr ipv4() :data{ {0, 0, 0, 0} } {}
That's correct. Thanks for pointing it out.
The default constructor initializes only the
data[0]
element:https://github.com/PacktPublishing/The-Modern-Cpp-Challenge/blob/a3eb81b153758c90f1de7a82792892814e69839e/Chapter02/problem_15/main.cpp#L10 \ For example, if you change the code as follows:
then
produces:
\ Possible fix: