私はメソッドが追加された公開されているテンプレートクラスを持っています。このクラスは名前空間Aにあります。今、私は別の名前空間(たとえばB)でこのメソッドを呼び出しています。最初に、コンパイラは、この特定のメソッドの「未解決の外部シンボル」と言ってリンカエラーを出しました。
しかし、このメソッドを同じ名前空間(つまりA)の中に呼び出すと、このメソッドはうまくリンクします。その後、名前空間Bでもうまくリンクします。
なぜこれが起こりうるのですか?
これは、私のクラスのテンプレート作成オブジェクトと関係がありますか?
アトゥール
ここでは、私は名前空間B内からこのメソッドを呼び出すいた場合、それは私が名前空間A内からこれを呼び出すときに、未解決の外部シンボルを与えるが、リンカーエラーを与えるテンプレートクラス
namespace sss
{
namespace AAA
{
template <<typename T, typename TAlloc = Allocator<T> >
class DLL_EXPORT A
{
public:
// Some other functions that are working fine ...
bool fooA() const;
{
return Size()>0;
}
};
}
}
//I get a linker error when I call it in another namespace (say B)...
//I am accessing this method in public method of some other class in namespace B
// Including the header for class A ...
#include A.h
namespace QQQ
{
namespace B
{
class B
{
private:
AAA::A obj; // Object of class A ...
public:
// SOme methods
// Method that calls fooA ...
GetResult()
{
fooA // This causes causes linker error when i call it here,
// but, it works when i call it in namespace AAA,
// and then it, it works here as well
}
};
、それがリンク...コードスニペットですよくAで、Bで再び。
アイデア
これを示す最小のコード例を提供できますか? –
コードを表示できますか? – UmmaGumma
私はちょうどtemplaet名前空間を意味するのだろうか? – UmmaGumma