Well a c++ program is a program written in C++, if I got your idea right. That means it does whatever you tell it to; you can easily write it in such a manner that it checks the arguments given, and if there is no -d argument, then skips the questions and uses default values (maybe by setting a flag which is checked later in the program, or something), or if the argument is given, then does ask the questions.
You'll write the program depending on what the program needs to do. Use argc and argv, which are given to main function as arguments, to determine the number of arguments given and the arguments themselves, and then deal with them the way you like.
EDIT: well here's a short example to demonstrate how it starts. It shows how to access the arguments; after this you'll want to test them and do whatever you want.
Code:
#include <iostream>
// Function main takes two arguments: argc, the number of arguments
// when the program is executed, which is one or more, and argv
// which contains those arguments in argv[0]...argv[argc-1]
int main(int argc, char **argv)
{
// Print out the number of arguments; note that if you
// start the program without any arguments except for
// the executable name, argc is 1 and not 0.
std::cout << "Number of arguments given: " << argc << std::endl;
int i=0; // index number for the loop
char Argument[10]; // char array of 10 elements to store
// the arguments one at a time
while (i < argc) // loop trough all the arguments
{
// copy the argument at hand in each round
// to Argument[], then print it and increase index
strcpy(Argument, argv[i]);
std::cout << "Arg " << i << " is " << Argument << std::endl;
i++;
}
return 0; // ...and return 0 to say we're clean
}
Sample outputs look like this:
1) without extra arguments
Quote:
$ ./a.out
Number of arguments given: 1
Arg 0 is ./a.out
|
2) with some arguments
Quote:
$ ./a.out A BB CCC
Number of arguments given: 4
Arg 0 is ./a.out
Arg 1 is A
Arg 2 is BB
Arg 3 is CCC
|