注册 登录
编程论坛 C++教室

这个报错是怎么回事?

苍穹之舞 发布于 2017-05-10 09:47, 3230 次点击
只有本站会员才能查看附件,请 登录


头文件不对?
6 回复
#2
苍穹之舞2017-05-10 09:52
只有本站会员才能查看附件,请 登录


同样的报错,郁闷

我因为猜不到代码的运行结果,所以就在VC上打了一遍,想运行一下,结果报错了

跪求各位大虾帮忙看看,毛病出在哪里?
#3
yangfrancis2017-05-11 22:19
已经提示得很清楚了,第三行的分号在哪里
#4
FollowDream2017-05-13 09:16
回复 2楼 苍穹之舞
你是哪个环境运行的?VC 2012么?

程序代码:
class Shit
    {
    private:
        int i=4;
    public:
        Shit(int i=3): i(i++) {}
        void display()
            {
            count << this->i;
            }
    };

我的Linux报错:
error: ISO C++ forbids initialization of member ‘i’
error: making ‘i’ static
ISO C++ forbids in-class initialization of non-const static member ‘i’
In constructor ‘Shit::Shit(int)’: ‘int Shit::i’ is a static data member; it can only be initialized at its definition
In member function ‘void Shit::display()’: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<<’
#5
rjsp2017-05-13 15:57
回复 4楼 FollowDream
他用的应该是vc6

关于你的代码,编译参数加 -std=c++11 或 -std=c++17 试试
#6
倾听心跳2017-05-13 21:54
都是符号问题,注意看报错解释
#7
iori2006hn2017-05-14 22:18
using namespace std后面需要加;
1