Pass arguments to a parameter class object
- by David R
This is undoubtedly a simple question. I used to do this before, but it's been around 10 years since I worked in C++ so I can't remember properly and I can't get a simple constructor call working.
The idea is that instead of parsing the args in main, main would create an object specifically designed to parse the arguments and return them as required.
So:
Parameters params = new Parameters(argc, argv)
then I can call things like params.getfile()
Only problem is I'm getting a complier error in Visual Studio 2008 and I'm sure this is simple, but I think my mind is just too rusty.
What I've got so far is really basic:
In the main:
#include "stdafx.h"
#include "Parameters.h"
int _tmain(int argc, _TCHAR* argv[])
{
Parameters params = new Parameters(argc, argv);
return 0;
}
Then in the Parameters header:
#pragma once
class Parameters
{
public:
Parameters(int, _TCHAR*[]);
~Parameters(void);
};
Finally in the Parameters class:
include "Stdafx.h"
#include "Parameters.h"
Parameters::Parameters(int argc, _TCHAR* argv[])
{
}
Parameters::~Parameters(void)
{
}
I would appreciate if anyone could see where my ageing mind has missed the really obvious.
Thanks in advance.