const

How can you make a constant in a class so that every instance has that constant.
but every instance has an other value in that constant, thus you have to assign a value to that constant once. How can you do that?
I am not sure I am understanding the question correctly.
Do you want to create a constant variable, which is a member of a class, but you also want to initialize the constant to a different value every time you create an object from the class?

If that is the case you could use use a private variable and initialize it to whatever you want using an accessor function.

Again I'm not sure I am understanding the question correctly, can you post some code of what you have been working on?
That is simply a non-static constant member variable


non-static constant member variables have to initialised in the constructor(s) initialisation list.
Topic archived. No new replies allowed.