Okay, MSVC6 is making me nuts because it errors for reasons I am unable to determine. I doubt there is a problem with my code because it compiles cleanly with Borland and the it is quite straightforward...
Here is exactly what I'm compiling with the errors listed on their corresponding lines. Any ideas?
Code:
Test.h
#include <iostream>
using namespace std;
class Test {
public:
Test();
Test(const Test &);
template <typename T>
Test(const T &);
Test& operator=(const Test &);
template <typename T>
Test& operator=(const T &);
};
Code:
Test.cpp
#include <iostream>
#include <string>
#include "Trash.h"
using namespace std;
Test foo() {
Test t;
t = string("foo");
return t;// 'Test::Test' : ambiguous call to overloaded function
// no legal conversion of return value to return type 'class Test *'
}
Test foo2() {
Test t;
t = foo();// 'operator =' is ambiguous
return t;// 'Test::Test' : ambiguous call to overloaded function
// no legal conversion of return value to return type 'class Test *'
}
int main() {
string str = "BLAH";
Test t(str);
Test t2;
t2 = str;
Test t3 = foo();// 'initializing' : cannot convert from 'class Test' to 'class Test'
// No copy constructor available for class 'Test'
return 0;
}
Test::Test() {
}
template <typename T>
Test::Test(const T &) {
}
Test::Test(const Test &) {
}
template <typename T>
Test& Test::operator=(const T &) {
return *this;
}
Test& Test::operator=(const Test &) {
return *this;
}