How to use a command line inside a header file ?


I am designing a music synthesizer in c++ using classes. I have to read a .csv file containing freq, amp and duration from inside a header file and it should be read from a command line.
Now I have problem. I can use command line in int main function and use it inside the function as,

int main(int argc, char *argv[])
{
if(argc!=2)
{
//codes
}

ifstream infile;
infile.open(argv[1])
.....
..... //codes

}

But how can I use it inside the header file which does not have int main() ?
unless the file name is going to not change, then you do not need to put it in the header file. Assuming that you want to open the file specified on the command line:

All you need to do is pass the file name to some object/function in your header file that does the opening.
My professor has asked explicitly to read the input file and write out from the command line and the file is to be read from the header file.
How can I dot it ?
I think you need to speak to your professor and get him to explain what he means first.
Topic archived. No new replies allowed.