g ++ error - expected nonqualified-id before')'token [英] g++ error - expected unqualified-id before ')' token

查看:251
本文介绍了g ++ error - expected nonqualified-id before')'token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译这个代码,它说它期望在我的构造函数之前的非限定id)

When I go to compile this code it says it expected an unqualified-id before the ) in my constructor

analysis2.h:

analysis2.h:

#ifndef _ANALYSIS2_H
#define _ANALYSIS2_H

class Analysis2{

public:

    Analysis2();
...

analysis2.cpp:

analysis2.cpp:

#include "analysis2.h"

using namespace std;

Analysis2()
{
    Seconds_v = 0;
    Seconds_t = 0;
}
...

如何解决这个问题?

推荐答案

analysis2.cpp 中,需要告诉编译器,构造函数:

In analysis2.cpp you need to tell the compiler that you are defining the constructor by giving it a scope:

Analysis2::Analysis2()
{
    Seconds_v = 0;
    Seconds_t = 0;
}

范围解析运算符

这篇关于g ++ error - expected nonqualified-id before')'token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆