If the goal is just to not have to create a .cpp
file, the
simplest solution would probably be to wrap the static data
member in an inline static member function. In other words,
something like:
struct Transport
{
static ServiceType& service()
{
static ServiceType theData;
return theData;
}
};
Of course, you'll have to use the syntax service()
, rather
than just service
, to access it.