MSVC: Why does use of enum without prior declaration compile?

While playing around with C++, I discovered that the following code enum E* kind; int main() { } compiles on MSVC v19.latest. I expected this to fail, as E is not declared yet. GCC and Clang give appropriate error messages error: use of enum ‘E’ without previous declaration and error: ISO C++ forbids forward references… Read More MSVC: Why does use of enum without prior declaration compile?

Create const std::vector as the concatenation of two const std::vector

I would like to create a const std::vector to contain all the elements of two other const std::vector of the same type. #include <iostream> #include <vector> int main() { const std::vector<int> int_a{0,1}; const std::vector<int> int_b{2,3}; const std::vector<int> all_ints; for (int i: all_ints) std::cout << i << ‘ ‘; return 0; } For the example above… Read More Create const std::vector as the concatenation of two const std::vector

Declare C++ Class (identifier logging is undefined)

I’m a complete newbie to C++ so bear with me. I am defining a class called ‘logging’ which is currently write in main.cpp. Now that I am trying to split implementation (log.cpp) from declaration (log.h), I have the following situation that bring me to compiler error ‘identifier logging is undefined’: log.cpp #include <iostream> #include <unordered_map>… Read More Declare C++ Class (identifier logging is undefined)

What does the variable array name at the end of the structure's definition means?

I’ve already read this, this and this but it seems they’re not exactly my situtation. I have a code like this struct ppl_weight { uint16_t weight; uint8_t weightHour; } ppl_weightList[16]; but I can’t understand the array at the end of the struct. What does it mean? Have I an array of 16 struct? How does… Read More What does the variable array name at the end of the structure's definition means?

Field '_areas' should be initialized because its type 'List<Area>' doesn't allow null

Flutter shows error Non-nullable instance field ‘_areas’ must be initialized. Maybe this is because of not defining null in lists areas what when defining null Like List? _areas; it shows an error on the index Error: Field ‘_areas’ should be initialized because its type ‘List’ doesn’t allow null. Error Line: List _areas; Here is my… Read More Field '_areas' should be initialized because its type 'List<Area>' doesn't allow null