I'm trying to implement scalar product in C++ inside a library:
namespace Foo
{
double operator* (vector<double> left, vector<double> right)
{
...
}
}
But I'm having problems calling it inside the main program. Calling
int main (void)
{
...
double result = Foo::operator* (l, r);
...
}
isn't a good solution, while:
int main (void)
{
...
double result = l * r; //l, r are vector<double>
...
}
isn't working.
using namespace Foo
is considered a bad practice for global usage.
What is a good way to call my operator*
fuction inside main
scope?