In porting some code I have a function (this is the original code). The
second parameter has a default. Array is a home grown class.
int foo(Array<aaa> &x, Array<bbb> *y = NULL);
What I want is to replace the home grown array classes with the STL
vector class. I also want to pass them by reference.
int foo(std::vector<aaa> &x, std::vector<bbb> &y);
But, this requires 2 parameters. Using vector, I could overload foo
with an inline single argument function that would achieve the desired
result.
inline int foo(std::vector<aaa> &x) {
std::vector<bbb> y; // empty vector
return foo(x, y);
}
Is there a good way where I could use a single function call, using
vector where the second parameter has a default value as the empty
vector. This would also achieve the desired result, but with a
performance hit if vector y is populated.
int foo(std::vector<aaa> &x, std::vector<bbb> *y =NULL);
--
Jerry Feldman