小编han*_*jin的帖子

C++:错误:预期';' 在声明列表的末尾(用clang ++ 3.4编译)

我试着写一个非常简单的进度条类.我将所有内容放入progressBar.h中,并创建了一个最小的测试用例.我在Ubuntu 14.04上使用clang ++ 3.4运行它.我包括-std = c ++ 11标志.测试用例创建了一个新的ProgressBar对象并调用成员函数displayProgress(double).我包括在ProgressBar.h中.

这是我的代码:

#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";
    }
};
Run Code Online (Sandbox Code Playgroud)

这是错误消息: …

c++ c++11 clang++

-1
推荐指数
1
解决办法
6586
查看次数

标签 统计

c++ ×1

c++11 ×1

clang++ ×1