Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ error - expected unqualified-id before ')' token

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

analysis2.h:

#ifndef _ANALYSIS2_H
#define _ANALYSIS2_H

class Analysis2{

public:

    Analysis2();
...

analysis2.cpp:

#include "analysis2.h"

using namespace std;

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

How do I fix this?

like image 258
mrswmmr Avatar asked Nov 20 '25 08:11

mrswmmr


1 Answers

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;
}

Scope Resolution Operator

like image 105
Chad Avatar answered Nov 21 '25 22:11

Chad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!