J
Jayden Shui
Hello All,
I have a global function to clone an object.
template<class T>
T* Clone(T const& t)
{
return new T(t);
}
and I have a class A in a namespace S which needs a specialized Clone
function
namespace S {
class A
{
friend A* Clone(A const& a)
{
// do something special
return new A(a);
}
};
};
The clone function for S::A is introduced in the namespace S, that is
S::Clone. It is not in the global scope. Is there any way to introduce
it in the global scope while still keeping the function body in the
namespace scope.
Thank you very much for your kind help!
Best regards,
Jayden
I have a global function to clone an object.
template<class T>
T* Clone(T const& t)
{
return new T(t);
}
and I have a class A in a namespace S which needs a specialized Clone
function
namespace S {
class A
{
friend A* Clone(A const& a)
{
// do something special
return new A(a);
}
};
};
The clone function for S::A is introduced in the namespace S, that is
S::Clone. It is not in the global scope. Is there any way to introduce
it in the global scope while still keeping the function body in the
namespace scope.
Thank you very much for your kind help!
Best regards,
Jayden