You need to tell the compiler that Settings
is in the scope of Foo
, since that's where it's defined.
This compiles just fine:
//foo.cpp
Foo::Settings Foo::GetSettings(){
}
Inside the class, you don't need to specify that, since the compiler considers all names in the scope of the class.
In this definition,
//foo.cpp
void Foo::SetSettings(Settings settings){
}
the compiler knows that you are defining a function of Foo
, so similarly, you don't have to specify the scope that the compiler should look at, for the function argument Settings
.
It might seem that the compiler should know that GetSettings
is also a function of Foo
. This is mostly right, and in fact, this compiles just fine:
auto Foo::GetSettings() -> Settings {
}
In this case, the compiler knows in which scope to look for the return type, by the time it has to figure it out.