0
我试图重新编译最新的Visual Studio(2008)中的旧代码,以前的工作代码现在无法编译。其中一个问题是由于我班的操作员负担过重。下面有简化课来演示问题。如果我删除int和char *的铸造操作符,那么它工作正常。所以解决我的问题的方法之一是将它们替换为to_char和to_int,然后使用它们,但它需要对代码进行大量更改(该类被大量使用)。必须有一些更好,更聪明的方法来解决它。任何帮助是极大的赞赏:-)模糊复制构造函数vc 2008
class test
{
public:
test();
test(char* s2);
test(int num);
test(test &source);
~test();
operator char*();
operator int();
};
test::test() {
}
test::test(char* s2) {
}
test::test(int num) {
}
test::test(test &source) {
}
test::operator char*() {
}
test::operator int() {
}
test test_proc() {
test aa;
return aa;
}
int test_proc2(test aa)
{
return 0;
}
int main()
{
test_proc2(test_proc());
}
//test.cpp(60) : error C2664: 'test_proc2' : cannot convert parameter 1 from 'test' to 'test'
// Cannot copy construct class 'test' due to ambiguous copy constructors or no available copy constructor
非常感谢!这种简单的解决方案。你救了我的一天:-) – 2009-12-30 03:47:08