Hello again , i have a question about static variables...
i have a class called circle and a class called cylinder( which inherirates circle). i think i've a good case for using statics's.....
I want to have a static variable in each class which denotes the largest radius in each class . i call it maxRadius
class circle
{ public :
static int maxRadius;
.....
class cylinder: public circle
{ public
static int maxRadius;
I tend to be cautious about using a static for something like this. But it really depends on your situation. I naturally tend to avoid committing to a global solution if there might be a possibility that a less than global solution could be required later on.
Will all of one class always have the same max radius? Is it possible you might want to have one group of the class with one max radius and a different group with another max radius?
There are other ways for multiple objects of a given class to share characteristics. You could pass each of them a pointer to some kind of shared 'limits' class object. That way you could independently manage multiple groups of your objects, each group having different shared attributes.
However, if your needs are simple, then simple solutions are the way to go. No point in over-engineering!