J
Julian
the following code compiles in g++ and .NET but i get the following error
when i compile it in VC6:
error C2667: '<<' : none of 2 overload have a best conversion (in the main
function)
error C2593: 'operator <<' is ambiguous
whats the problem here ??
i'm just shooting in the dark here but is there some setting in vc6 when i
can tell it to compile using ansi standards ?
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class MultiStreamWriter {
private:
vector<ostream *> m_vecWriters;
public:
MultiStreamWriter(void) {
Log.open("log.txt");
}
~MultiStreamWriter(void) {
Log.close();
}
ofstream Log;
template<typename Type>
friend MultiStreamWriter & operator << (MultiStreamWriter &a_mswWriter,
const Type &a_typOutput);
};
template<typename Type>
MultiStreamWriter & operator << (MultiStreamWriter &a_mswWriter, const Type
&a_typOutput) {
a_mswWriter.Log << a_typOutput;
cout << a_typOutput;
return a_mswWriter;
}
int main(void) {
MultiStreamWriter l_mswWriter;
l_mswWriter << "file one and file two\n";
}
when i compile it in VC6:
error C2667: '<<' : none of 2 overload have a best conversion (in the main
function)
error C2593: 'operator <<' is ambiguous
whats the problem here ??
i'm just shooting in the dark here but is there some setting in vc6 when i
can tell it to compile using ansi standards ?
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class MultiStreamWriter {
private:
vector<ostream *> m_vecWriters;
public:
MultiStreamWriter(void) {
Log.open("log.txt");
}
~MultiStreamWriter(void) {
Log.close();
}
ofstream Log;
template<typename Type>
friend MultiStreamWriter & operator << (MultiStreamWriter &a_mswWriter,
const Type &a_typOutput);
};
template<typename Type>
MultiStreamWriter & operator << (MultiStreamWriter &a_mswWriter, const Type
&a_typOutput) {
a_mswWriter.Log << a_typOutput;
cout << a_typOutput;
return a_mswWriter;
}
int main(void) {
MultiStreamWriter l_mswWriter;
l_mswWriter << "file one and file two\n";
}