cpp:在'。'标记之前预期的primary-expression

时间:2017-02-14 10:51:14

标签: c++ class static static-members

我有以下代码:

class SSLHashSHA1
{
    SSLHashSHA1();
    ~SSLHashSHA1();
    public:
        static OSStatus update(string*, int*);
        static OSStatus final (string*, string*);
};

OSStatus SSLHashSHA1::update(string* ctx, int* ran){
    return 0;
}

OSStatus SSLHashSHA1::final(string* ctx, string* out){
    return 0;
}

static OSStatus SSLVerifySignedServerKeyExchange(
    SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, uint16_t signatureLen)
{
    OSStatus err;

    if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
        goto fail;
    if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
        goto fail;
        goto fail;
    if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
        goto fail;


    fail:
        SSLFreeBuffer(&signedHashes);
        SSLFreeBuffer(&hashCtx);
        return err;
}

我收到了标题中提到的错误。 我得到了SSLHashSHA1.update和SSLHashSHA1.final调用。 为什么我会这样做?

我想当我将类成员函数设为静态时,我可以使用它而不必创建对象。或者我应该将类更改为结构或类似的东西?

1 个答案:

答案 0 :(得分:3)

SSLHashSHA1.update()

这是完全错误的,SSLHashSHA1是一个类,而不是一个实例,所以你不能使用.运算符在这里调用一个方法,相反,如你所提到的,你的{{1} 1}}是一个静态函数,因此使用范围解析运算符(update)调用它,如下所示:

::