converting method from java to c++

I am not very well versed in c++. I need a little bit of help with some code in converting a simple method in java to c++.

In java I would write this:

private boolean check(){
if (sides[0] < (sides[1]+sides[2]))
return true;
else
return false;
}


however, when I try to write write the following in c++, the code doesnt seem to work:
bool check(){
if (sides[0] < (sides[1]+sides[2]))
return true;
else
return false;
}


what am i doing wrong? how would i do this in c++.
thanks in advance!
If 'sides' is not declared as a global array, you'll get a compiler error. At first glance, I'd say that Java function was poorly written to begin with. 'sides' shouldn't be a global.
I'd rewrite the signature to this: bool check(/*int?*/ *sides)
(In C/++, T *array and T array[] are equivalent for declarations.)
At first glance, I'd say that Java function was poorly written to begin with. 'sides' shouldn't be a global.


err... Java, unlike C++ forces OO. So sides would've been a member variable of the class that check() belonged too.

Same thing applies to C++, if sides was a member variable then the code would work fine in both Java and C++.
Topic archived. No new replies allowed.