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?
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
In analysis2.cpp
, write this:
Analysis2::Analysis()
{
Seconds_v = 0;
Seconds_t = 0;
}
You have to include the class name (Analysis2::
).
Type
Analysis2::
before the method name or constructor/destructor
You need to specify Analysis2::Analysis2()
if you are trying to define a constructor. Otherwise, the compiler supposes that the Analysis2
is the name of a type in a declaration of something else.