노출 된 템플릿 클래스가 있는데 여기에 메서드가 추가되었습니다. 이 클래스는 네임 스페이스 A에 있습니다. 이제이 메서드를 다른 네임 스페이스 (예 : B)에서 호출합니다. 처음에는 컴파일러가이 특정 메서드에 대해 "해결되지 않은 외부 기호"라고 말하는 링커 오류를주었습니다.
그러나이 메서드를 동일한 네임 스페이스 (즉 A) 내에서 호출하면 잘 연결됩니다. 그런 다음 네임 스페이스 B에서도 잘 연결됩니다.
왜 이런 일이 일어날 수 있습니까?
내 클래스의 템플릿 생성 객체와 관련이 있습니까?
아툴
여기 는링커 오류를주는 템플릿 클래스
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를 내에서이 호출 할 때, 그것은 링크, 확인되지 않은 외부 기호를 제공하지만 ... 코드 조각입니다 잘 A에서, 그리고 다시 B에서.
아이디어가 있으십니까?
이를 증명하는 최소한의 코드 예제를 제공 할 수 있습니까? –
코드를 보여줄 수 있습니까? – UmmaGumma
저는 templaet 네임 스페이스가 무엇을 의미하는지 궁금합니다. – UmmaGumma