[問題] c++中的sealed物件
請問一下各位
網路上有一些文章有教各位如何實做sealed物件
但是我照他們的方法實做之後卻無法編譯
請各位幫我指點一下問題
謝謝
以下是我的程式碼
template<typename T>
class Sealed
{
protected:
Sealed(){}
};
template<typename T>
class SealedSingleton : private virtual Sealed<T>
{
private:
friend typename T;
public:
SealedSingleton(){}
};
然後錯誤訊息是
../SealedSingleton.h:17: error: expected nested-name-specifier before 'T'
../SealedSingleton.h:17: error: 'T' is neither function nor member function;
cannot be declared friend
我使用的編譯器是g++ 4.2.4
作業系統是AIX 5.2
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.220.71.34
→
10/25 16:44, , 1F
10/25 16:44, 1F
→
10/25 16:45, , 2F
10/25 16:45, 2F
→
10/25 16:48, , 3F
10/25 16:48, 3F
推
10/25 17:08, , 4F
10/25 17:08, 4F
→
10/25 17:22, , 5F
10/25 17:22, 5F
→
10/25 17:24, , 6F
10/25 17:24, 6F
→
10/25 17:28, , 7F
10/25 17:28, 7F
→
10/25 17:28, , 8F
10/25 17:28, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章