本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 17:30