|
|
От: |
O-Sam
|
|
| Дата: | 26.07.04 12:04 | ||
| Оценка: | |||
GIV> ostream& operator<< (ostream& s, const Complex& z)
GIV>Z:\Heap\Coding\Cpp\iotest\main.cpp(30) : error C2593: 'operator <<' is ambiguous
Error executing cl.exe.
#include <iostream>
using namespace std;
class Complex
{
double re;
double im;
public:
Complex (double re, double im);
double real() const {return re;}
double imag() const {return im;}
friend ostream& operator<< (ostream& s, const Complex& z);
};
Complex::Complex (double re, double im)
{
this->re = re;
this->im = im;
}
ostream& operator<< (ostream& s, const Complex& z)
{
return s << '(' << z.real() << ',' << z.imag() << ')';
}
void main(void)
{
Complex a(1.2,0.2);
cout << "a=" << a;
}