So far all I have in my DecisionTree.h
file is
namespace DecisionTree
{
public static double Entropy(int pos, int neg);
}
and Visual Studio is already highlighting the public
and saying
Error: expected a declaration.
What am I missing?
'Expected declaration` basically means that you should have defined something before using it. There are multiple fixes to this error: If you are trying to declare a variable or constant, be sure that you have a let or var at the beginning.
Normally that error occurs when a } was missed somewhere in the code, for example: void mi_start_curr_serv(void){ #if 0 //stmt #endif. would fail with this error due to the missing } at the end of the function. The code you posted doesn't have this error, so it is likely coming from some other part of your source.
It means the syntax is invalid.
The expected unqualified id error shows up due to mistakes in the syntax. As there can be various situations for syntax errors, you'll need to carefully check your code to correct them. Also, this post points toward some common mistakes that lead to the same error.
public
is an access specifier. Access specifiers are applicable only within class/struct
body and not inside namespace
. In C++ (unlike Java) it must be followed by a colon :
inside the class
body.
For example,
class DecisionTree { // <----- 'class' (not 'namespace')
public: // <------ access specifier
static double Entropy (int pos, int neg);
private:
int i;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With