I don't know if this is even possible, but can you set a default function pointer in a function's calling signature, like
you can for passing ints or floats, so one doesn't need to be passed all the time? If so -- how? I'm having trouble with
the syntax.
Below is my calling procedure, which you can see I pass a functor pointer, but I'd like to set a default so I don't need to
pass a functor pointer every time. This is because most of the time I should just use a default function ptr.
The errors I get are:
1) invalid use of member 'MyTable:aram' -- this is a private data member of MyTable: why can't it be used here?
2) 'parameterNumber' was not declared in this scope: it's on the stack already isn't it? why can't it be used??
Code:
Boolean MyTable::GetData(int beginTimestamp, int endTimestamp, string & output, const uint parameterNumber, const uint dataType)
{
switch (dataType)
{
case 1:
{
//create our functor objects
AbstractFunctor* functorPtrLow = new T_SpecificFunctor<MyParameter> (param[parameterNumber], &MyParameter::GetLowerROCGraphBoundary);
//use the specific function ptr I tell it to use....
Boolean returnvalue = GetData(beginTimestamp, endTimestamp, output, parameterNumber, &MyTable::GetRateOfChange, functorPtrLow);
delete functorPtrLow;
functorPtrLow = NULL;
return (returnvalue);
}; //end case
case 2:
{
//use "default" function ptr.....................................................................no 6th parameters passed here
Boolean returnvalue = GetData(beginTimestamp, endTimestamp, output, parameterNumber, &MyTable::GetStandardDeviation);
return (returnvalue);
}; //end case
.......
} //end switch
} //end MyTable::GetData(...)
This is my actual method signature, and I've tried various ways, but I can't get the default parameter syntax right.
Code:
protected:
virtual Boolean MyTable::GetData(int beginTimestamp, int endTimestamp, string & output, const uint parameterNumber,
Boolean (MyTable::* QAMethod)(float & value, const int timestamp, const uint param_number),
AbstractFunctor* lowFcn = T_SpecificFunctor<MyParameter> (param[parameterNumber], &MyParameter::DefaultFunction));
I could do a "if ptr is NULL, use this function" in GetData(...), then pass NULL ptrs, but I was hoping there'd be a more elegant way....
Thanks for any help....