Hello, I am having a little trouble with some syntax.
I am making a Configuration class.
In configuration.h I have something like this.
There are lots of configuration variables orginized into structs like so. And then there is the Default struct, that has all the structs, again, and this is used to store the default configuration values.Code:class Configuration { public: struct Position { int x; int y; } Position; static const struct Default { static const struct Position { static const int x; static const int y; } Position; } Default; };
In my configuration.cpp, I would have:
But I keep getting the following errors for the lines in .cpp file where I initialize the default stuff. So each line generates this pair of errors:Code:#include "configuration.h" /* set all the defaults */ const int Configuration::Default.Position.x = 10; const int Configuration::Default.Position.y = 10; //... Configuration::Configuration() { read(); // read the settings or set them to the default values } //...
If its of any relevance, The Configuration class has a private constructor,a nd private copy constructor, and is accessed using a friend function.error: expected init-declarator before '.' token
error: expected `,' or `;' before '.' token
so in configuration.h:
and in configuration.cpp:Code:private: Configuration(); Configuration(const Configuration&); ~Configuration(); // allow this function to create one instance friend Configuration& Config();
What am I doing wrong?Code:Configuration& Config() { static Configuration conf; return conf; }
Thanks,
Latem




Reply With Quote