J
John Smith
Hello group.
In the following snipet of code is it guaranteed that foo::coords_
will be initialized before foo::active_coord_ ?
I mean is it guaranteed that the reference &active_coord_ will be
valid ?
Thanks a lot for your response.
//
----------------------------------------------------------------------------------------------------------------------------
#include <vector>
#include <iostream>
class foo {
public:
static std::vector<size_t> coords_;
static size_t &active_coord_;
};
std::vector<size_t> foo::coords_( 1 );
size_t &foo::active_coord_ = coords_[ 0 ]; // Is it safe ?
int main() {
foo ob;
foo::coords_[ 0 ] = 10;
std::cout<<" active coord is "<<ob.active_coord_<<"\n";
return 0;
}
In the following snipet of code is it guaranteed that foo::coords_
will be initialized before foo::active_coord_ ?
I mean is it guaranteed that the reference &active_coord_ will be
valid ?
Thanks a lot for your response.
//
----------------------------------------------------------------------------------------------------------------------------
#include <vector>
#include <iostream>
class foo {
public:
static std::vector<size_t> coords_;
static size_t &active_coord_;
};
std::vector<size_t> foo::coords_( 1 );
size_t &foo::active_coord_ = coords_[ 0 ]; // Is it safe ?
int main() {
foo ob;
foo::coords_[ 0 ] = 10;
std::cout<<" active coord is "<<ob.active_coord_<<"\n";
return 0;
}