Hi All
Given the following:
// NamespaceTemplate.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
namespace N1
{
class C1
{
public:
void f() {}
void g() {}
};
class C2
{
public:
void h(C1 info) {}
void i() {}
};
}
namespace N2
{
class C1
{
public:
void f() {}
void g() {}
};
class C2
{
public:
void h(C1 info) {}
void i() {}
};
}
template <typename T>
void k(T x)
{
C1 theProblem; // Ambiguous!! How to create the correct object???
x.h(theProblem);
x.i();
}
using namespace N1;
using namespace N2;
int main(int argc, char* argv[])
{
N1::C2 b;
k(b); // Invoke Template function
N2::C2 d;
k(d); // Invoke Template function
return 0;
}
What is the best way (that is, the most common way) to resolve the
issue above? I get an ambiguous symbol error when compiling, which
does make sense. I'm looking for a way to resolve this without
resorting to passing in enumerated types representing objects or
something like that.
Thanks.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]