Is it correct to use the member of a struct that we are initializing? My compiler does not complain with the following code:
#include <iostream>
struct Foo {
int a, b;
};
int main() {
Foo foo {34, foo.a + 2}; // I'm using `foo.a` during the `foo` initialization
std::cout << foo.a << " " << foo.b << std::endl;
return 0;
}
// Prints "34 36"
But it seems weird since foo
is not declared yet when I use it inside the braces.