I''m interested in saving some basic configuration info in my class. The problem is that the values I want to use are objects that need to be constructed. For example, say I wanted to store the default gravity as a Vector(0, 0, -9.8) and the default sound as a Sound("boing.wav"). What I *want* is to be able to put at the top of my Environment class something like:
class Environment
{
const Sound defaultSound = Sound("boing.wav");
const Vector gravity = Vector(0, 0, -9.8);
...
Obviously, that''s not legal. The closest thing I can come up with is:
class Environment
{
Sound defaultSound;
Vector gravity;
Environment()
{
defaultSound = Sound("boing.wav");
gravity = Vector(0, 0, -9.8);
}
...
I find the second way very cumbersome and unintuitive - and worst of all, I can''t make those values const. Does anyone see what I''m talking about, and know a way to get close to the desired effect?
Thanks for any feedback~