I tried to write a very simple progressbar class. I put everything into progressBar.h, and created a minimal test case. I am running this on Ubuntu 14.04, using clang++ 3.4. I included -std=c++11 flag. The test case created a new ProgressBar Object and call the member function displayProgress(double). I included and in ProgressBar.h.
Here is my code:
#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";
}
};
Here is the error message:
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.