I came across some C ++ code that looks like this (simplified for this post):
(Here the function prototype is in someCode.hpp )
void someFunction(const double & a, double & b, const double c = 0, const double * d = 0);
(Here is the first line of the function body located in someCode.cpp , which is #include someCode.hpp )
void someFunction(const double & a, double & b, const double c, const double * d);
Can I legally call someFunction using:
someFunction(*ptr1, *ptr2);
and / or
someFunction(*ptr1, *ptr2, val1, &val2);
where are the variables ptr1 , ptr2 , val and val2 defined accordingly, and val1 and val2 not equal to zero? Why or why not?
And if this is legal, is this syntax preferable to overloading a function to account for additional parameters?
source share