如何将这个VC++ 6代码转换为VC++ 2008?

Nei*_*l N 2 c++ visual-studio-2008 visual-studio visual-c++

原谅我,我的C++非常生疏.但我正在尝试使用一些旧代码并在Visual C++ 2008下重新编译它.它最初是为Visual C++ 6.0编写的

我得到的错误是这样的:

错误C4430:缺少类型说明符 - 假定为int.注意:C++不支持default-int

好吧看起来很简单.但后来我看看有问题的代码行:

operator=(int i) {SetAsInt(i);};
Run Code Online (Sandbox Code Playgroud)

并且它似乎声明了类型IS.那我错过了什么?

跟进:

我接受了Micheals的建议并添加了函数的返回类型(类),并添加了返回; 到每个人的结尾.然后我碰到了这个:

operator=(const CString& str);
Run Code Online (Sandbox Code Playgroud)

没有定义功能体......究竟是什么意思?

Mic*_*urr 7

你需要让operator=()方法返回一些东西(如果诊断不是错误,它将假设为int,因为错误消息有点令人困惑地指示).

通常,它将是对操作员正在处理的对象的引用,因此可以将分配链接为正常的赋值表达式.就像是:

// where T is the class for this operator= implementation

T& operator=( int i) {
     // ...
    return *this;
}
Run Code Online (Sandbox Code Playgroud)