0

私はこれに取り組んできましたが、コンパイラからこのエラーを取得する準備がほぼ整いました。しかし、コンパイラはい!)、何か助けを得ることができますか? thx事前に、これがコードです

static int aDefaultValue=0;
//class T;
template <typename T>
class Servant
{
public:
    typedef typename T & ReferenceType;
    typedef const typename T * ConstPtrType;
    typedef typename T * ptrType;
    Servant(){}

    ptrType analizarQos(ptrType aMetodo= 0,int & aResult = aDefaultValue)
    {
        if (!aMetodo)
        {
            aResult=-1;
            return aMetodo;
        }
        //check for timeout del metodo
        //lleno el mensaje con la info

    }

private:
    ~Servant(){}
    //avoid copias
    Servant(const Servant &);
    const Servant & operator=(const Servant &);
};
4

2 に答える 2

1

あなたは必要になるでしょう

Servant(const Servant<T> &);
const Servant & operator=(const Servant<T> &);

禁止された操作 (少なくとも「injected-class-name」をサポートしていないコンパイラの場合)。

テンプレート パラメーターを指定せずに class の前方宣言を行ってServantいるか、テンプレート パラメーターの数が間違っている可能性があります。

于 2013-08-09T13:00:35.280 に答える
0

Clangが出力します

/private/tmp/my.cpp:7:22: error: expected a qualified name after 'typename'
typedef typename T & ReferenceType;
                 ^
/private/tmp/my.cpp:8:28: error: expected a qualified name after 'typename'
typedef const typename T * ConstPtrType;
                       ^
/private/tmp/my.cpp:9:22: error: expected a qualified name after 'typename'
typedef typename T * ptrType;
                 ^
3 errors generated.

次のように変更した後にコンパイルされたコード:

typedef T & ReferenceType;
typedef const T * ConstPtrType;
typedef T * ptrType;
于 2013-08-09T20:11:41.853 に答える