От: | ssi | ||
Дата: | 18.02.04 20:03 | ||
Оценка: |
class Ostream
{
std::ostream* stream_;
public:
...
virtual std::ostream& stream() { return *stream_; }
};
class Ofstream : public Ostream
{
std::ofstream fstream_;
public:
...
std::ofstream& stream() { return fstream_; }
};
10.3.5. The return type of an overriding function shall be either identical to the return type of overridden function or covariant with the classes of the functions. If a function D::f overrides a function B::f, the return types of the functions are covariant if they satisfy the following criteria:
...
the class in the return type of B::f is the same class as the class in the return type of D::f or, is an unambiguous direct or inderect base class of the class in the return type of D::f and is accessible in D
error C2555: 'Ofstream::stream' : overriding virtual function differs from 'Ostream::stream' only by return type or calling convention