3 ms·
I haven't been using C++ for a number of years but I think you could set the default values of fields even back then. Something like struct test {
by mrighele 1y ago
I haven't been using C++ for a number of years but I think you could set the default values of fields even back then. Something like
struct test {
int my_int = 0;
int* my_ptr = std::nullptr;
};
Or is this something more recent ?
You cannot initialize them with a different value unless you also write a constructor, but it not the issue here (since you are supposed to read them from the file system)
- MrRadar 1y agoThat's C++11 syntax. Before then you'd have to manually initialize them in every constructor, with a hand-written default constructor as a minimum: struct test { int my_int; int *my_ptr; test() : my_int(0), my_ptr(NULL) {} };