静的手段という用語とその仕組みを理解するのに苦労しています。ここでは、静的変数「フロート パーセンテージ」を初期化しました。convertToPercent() を使用してパーセンテージに変換する必要があり、変換後、値を取得して値を someMethod () に入れて計算を行う必要があります
以下は私が持っているものです
.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;
}
ただし、エラーメッセージが表示されます
Undefined symbols for architecture x86_64:
"Foo::percentage", referenced from:
Foo::convertToPercent() in Foo.o
与えられた助けに感謝します。ありがとう