0
我已經奮戰了一夜的編譯器和我江郎才盡......CRTP內部命名空間VS typdefs和朋友
我有了一個保護功能的命名空間內CRTP建設。 派生類(也在該名稱空間內)被typedefed爲另一個名稱。
旁邊,我有一個類(也typedefed到另一個名稱)與靜態函數,試圖調用該函數。所以我開始交朋友,但仍然是編譯器(在我的情況下,VS 2010)不會讓我訪問該函數。
一些代碼可能更清楚:
namespace foobar
{
namespace internal
{
template <typename T>
class A
{
friend class E;
protected:
void foo()
{
static_cast<T*>(this)->_foo();
}
};
class B : public A<B>
{
friend class E;
friend class A<B>;
protected:
void _foo()
{
printf("Foo from B\n");
}
};
}
typedef internal::B C;
class D
{
public:
static void Bar();
};
typedef D E;
void D::Bar()
{
C mB;
mB.foo();
}
}//foobar namespace
有誰能夠告訴我什麼我不是在這裏看到的和這可怎麼解決?
歡呼
Thx!這解決了它完美。 – moiself 2012-03-07 23:07:52