M
Marco T.
Hi all,
why the former code fragment works and the latter doesn't?
=============
//CORRECT CODE:
namespace ciao
{
class A{};
A operator *(A &a, A &b) {return a;};
A method() ;
}
using namespace ciao;
A method() {A a1,a2; return a1*a2;}
=============
//INCORRECT CODE
namespace ciao
{
class A{};
A operator *(A &a, A &b);
A method() ;
}
using namespace ciao;
A operator *(A &a, A &b) {return a;}
A method() {A a1,a2; return a1*a2;} //line X
error: 'operator *' is ambiguous at line X
(compiler: VC++ 6.0)
=============
The issue is that I don't want to write the implementation of operator
* inside the namespace declaration.
thanks
marco
why the former code fragment works and the latter doesn't?
=============
//CORRECT CODE:
namespace ciao
{
class A{};
A operator *(A &a, A &b) {return a;};
A method() ;
}
using namespace ciao;
A method() {A a1,a2; return a1*a2;}
=============
//INCORRECT CODE
namespace ciao
{
class A{};
A operator *(A &a, A &b);
A method() ;
}
using namespace ciao;
A operator *(A &a, A &b) {return a;}
A method() {A a1,a2; return a1*a2;} //line X
error: 'operator *' is ambiguous at line X
(compiler: VC++ 6.0)
=============
The issue is that I don't want to write the implementation of operator
* inside the namespace declaration.
thanks
marco