I am trying to make a class called "Arguments" which will handle all the arguments for my program.
There is a void function inside the class that will:
-take any arguement who's argv[0] = "-" or "/"
-evaluate the rest of the characters one by one, and adjust boolean values of flags as necessary.
Currently I have these boolean values defined private and static inside the Arguments definition. Now I'm not sure that was the best way to define them.
I wanted to avoid global variables. Since my program will completely process one argument before moving on to the next it seemed like using static makes sense.
My understanding of static variable, once assigned is that it CAN be changed however whatever it's value is, it is universal for all members of that class.
If I'm wrong there, I guess I'll have to try something else. However, if I'm right, I can't figure out how to set preliminary values for these flags.
Like I said, they are defined in the definition, but I need to predefine them as false. With other non-static variable I was able to do this in the constructor.
No matter what I try I can't seem to define these.
Are you sure that these variables should be static? If a constructor of an object need to initialize static variable when they are candidates to be non-static.
static variables are usually initialized independently of any object of the class. For example
1 2 3 4 5 6
struct A
{
staticbool flag;
};
bool A::flag;
In this example flag will be initialized by false.
Or you can reset values of static variables in a constructor of the class
1 2 3 4 5 6 7
struct A
{
A() { flag = true; }
staticbool flag;
};
bool A::flag;