Hello everybody,
I'm using OS X Mavericks (latest version) and Xcode (also latest version).
I'm trying to write some functions.
Here are the files
formula.h
This defines mathematical functions in a class
e.g.:
Inside the formula.cpp the Power function is defined as
Now I have a third file called constantPhysics.h
There is a line:
This way I get two "issues" (where I'm not if I can ignore them or not)
First: Use of undeclared identifier 'Power'; did you mean 'maFormula:
ower'?
Second: Call to non-static member function without an object argument
Now the funny thing that keeps me wondering: If I change the Power to maFormula:
ower(...) as suggested in the first "issue" this one is gone but the second keeps staying.
When I now change my own function to the one in math defined pow() function both "issues" are gone. Since my function is almost the same as the one in the standard library, I wondered why I get the two "issues".
Am I missing something or...
Anybody any idea?
BTW: all g... are constants, based on SI standards and are actually 1
I'm using OS X Mavericks (latest version) and Xcode (also latest version).
I'm trying to write some functions.
Here are the files
formula.h
This defines mathematical functions in a class
e.g.:
Code:
class maFormula {
public:
// Mathematical functions
double Power(double a, double b);
};
Inside the formula.cpp the Power function is defined as
Code:
double maFormula::Power(double a, double exp) {
double result = 1;
if (exp > 1) {
for (int i = 0; i < exp; i++) {
result *= a;
}
} else {
for (int i = 0; i > exp; i--) {
result /= a;
}
}
return result;
}
Now I have a third file called constantPhysics.h
There is a line:
Code:
const double gVolt = (1000 * gMetre) * (gMetre * gMetre) * Power(gSecond, -3) * gAmpere;
This way I get two "issues" (where I'm not if I can ignore them or not)
First: Use of undeclared identifier 'Power'; did you mean 'maFormula:
Second: Call to non-static member function without an object argument
Now the funny thing that keeps me wondering: If I change the Power to maFormula:
When I now change my own function to the one in math defined pow() function both "issues" are gone. Since my function is almost the same as the one in the standard library, I wondered why I get the two "issues".
Am I missing something or...
Anybody any idea?
BTW: all g... are constants, based on SI standards and are actually 1
Last edited: