-3
私は非常に単純なプログレスバークラスを作成しようとしました。私はprogressBar.hにすべてを入れて、最小のテストケースを作成しました。私はclang ++ 3.4を使ってUbuntu 14.04でこれを実行しています。私は-std = C++ 11フラグをインクルードしました。テストケースは新しいProgressBarオブジェクトを作成し、メンバー関数displayProgress(double)を呼び出します。私はProgressBar.hにインクルードしました。ここでC++:エラー:予期した ';'宣言リストの最後に(clang ++ 3.4でコンパイル)
は私のコードです:ここでは
#include <ostream>
#include <string>
class ProgressBar
{
private:
std::ostream& out;
int width;
public:
ProgressBar(std::ostream& out, int _width = 80):out(out) {
width = _width - 9;
}
void displayProgress(double percentage) {
out << "\r[" << fixed << setprecision(2) << percentage * 100 << "%]";
for (int i = 0; i < width * percentage; ++i) out << "=";
if (percentage != 1) out << ">";
else out << "O";
}
};
はエラーメッセージです:
In file included from test.cpp:2:
./progressBar.h:11:52: error: expected ';' at end of declaration list
ProgressBar(std::ostream& out, int _width = 80):out(out) {
^
;
test.cpp:8:4: error: no member named 'displayProgress' in 'ProgressBar'
p.displayProgress(0.5);
~^
2 errors generated.