【问题标题】:That darn C2679 error again VC++VC++又出现了那个该死的C2679错误
【发布时间】:2010-05-20 13:24:08
【问题描述】:

有一个包含保存数据的成员的 Day 类。

我有一个包含 Day 对象数组的 RedBlackTree 类。

Day m_list[MAX_LIST];

上面这段代码导致了这个错误:

错误 3 错误 C2679:二进制“=”:未找到采用“const Month”类型的右侧操作数的运算符(或没有可接受的转换)c:\program files\microsoft visual studio 8\vc\包括\xutility 2949

int m_list[MAX_LIST];

当我用 Day 代替整数时,我没有收到错误。我在日间课上缺少什么。 我确实有这个运算符=

const Day & Day::operator=(Day &otherDay)
{
    if(this != &otherDay)       // avoid self copy
        Copy(otherDay);

    return *this;
}

【问题讨论】:

    标签: visual-c++ compiler-errors


    【解决方案1】:

    它抱怨Day 缺少一个operator=,它采用const Month& 类型的参数。

    xutility 标头是 Visual Studio 提供的标准库实现的内部标头。查看第 2949 行所在的函数,这将为您指明问题的方向。

    【讨论】:

    • 注意运算符取const Month&,取值也有可能出错,如Month&
    • 好吗?我不认为我有任何代码希望 Day = const Month 我只能认为在我的 Month 类中,我没有 operator=。除此之外,我应该在我的项目中寻找什么代码?
    • 还有人可以解释一下为什么我会通过让该行创建天数数组来得到这个错误吗?
    猜你喜欢
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多