When declaring and implementing a class or struct in c++ we generally do:
H file
namespace Space{
class Something{
void method();
}
}
CPP file
void Space::Something::method(){
//do stuff
}
OR
namespace Space{
void Something::method(){
//do stuff
}
}
Note how it is possible to wrap all the implementations inside the namespace block so we don't need to write Space:: before each member. Is there a way to wrap class members in some similar way?
Please note I want to keep source and header file separated. That's generally a good practice.
Not without sacrificing the separation between header and implementation (cpp) file.
You can declare everything inline in the header inside the class, but it's very messy for large classes.
What's the problem you're actually trying to solve? Or is it just typing time? :)
Yes:
.h
file:
namespace Space{
class Something{
void method()
{
// do stuff
}
};
}
I don't recommend it, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With