I am struggling to understand the term static means and how it works. here I initialized a static variable "float percentage". and I have to convert it to percentage using convertToPercent() and after converting it I have to take the value and put the value to someMethod () to do some calculations
below is what I have
.h
class Foo {
private:
static float percentage;
public :
float convertToPercent();
};
.cpp
float Foo::convertToPercent() {
percentage = (30/100) * 100;
return percentage;
}
static float someMethod () {
//place the static percentage value here after doing convertToPercent() method to do some calculation;
}
however it throws me an error message
Undefined symbols for architecture x86_64:
"Foo::percentage", referenced from:
Foo::convertToPercent() in Foo.o
Apperciate for help given. thanks