Mail Archives: djgpp/2002/07/14/17:19:23
Hi,
I have a little problem
-8<-----------------------------------------------
#include <iostream.h>
#include <fstream.h>
class coWidth {
public : int m; coWidth(int a) : m(a) { }
};
ofstream& operator<<(ofstream &s, coWidth cmd) {
return s;
}
int main() {
ofstream s;
s<<' ';
return 0;
}
-8<-----------------------------------------------
This source generates error :
tmp.cpp(14) Error: choosing `std::basic_ostream<char, _Traits>&
std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits
=
std::char_traits<char>]' over `std::ofstream& operator<<(std::ofstream&,
coWidth)'
tmp.cpp(14) Error: because worst conversion for the former is better than
worst
conversion for the latter
There were some errors
I wanted to use class coWidth only manual s<<coWidth(5) and NOT to use it
automaticly s<<' ';
one of work arounds colud be to change :
coWidth(int a,char z)
what is the best work around ?
==================
making the only constructor private :
class coWidth {
private :
int m;
coWidth(int a) : m(a) { }
};
didn't help neither... why ?
i'm using GCC 3.04
--
Rafał 'Raf256' Maj
- Raw text -