Usually I have something like:
class simpledata { public: simpledata(int v1, int v2) : m_v1(v1), m_v2(v2) { } const int m_v1, m_v2 ; } ;
This way I can let others see m_v1 & m_v2 and not worry about the values getting modified. Unfortunately it doesn't work with char[].
class simplestringdata { public: simplestringdata(int v1, char * s1) : m_v1(v1) { strcpy(m_s1, s1) ; // XX - not allowed } const int m_v1 ; const char * const m_s1[MAXSIZE] ; } ;
My solution is let const members be modified in the constructor. It seems the right thing to do, after all you can do it in the initialization list, why not the constructor. Maybe special case it to only allow it for const int members at the same level, ie you can't modify const members of your parent. (Or maybe you could ...)
And no, the answer is not to use the 'string' class.
Feb '04
Oops I dropped by satellite.
New Jets create excitement in the air.
The audience is not listening.
Mar '04
Neat chemicals you don't want to mess with.
The Lack of Practise Effect
Apr '04
Scramjets take to the air
Doing dangerous things in the fire.
The Real Way to get a job
May '04
Checking out cool tools (with the kids)
A master geek (Ink Tank flashback)
How to play with your kids