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_; }
};
Насколько я понимаю, по стандарту здесь должно быть все в порядке, поскольку std::ofstream наследник std::ostream:
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
cl 12.00.8804 (VC6 SP5) выдает:
error C2555: 'Ofstream::stream' : overriding virtual function differs from 'Ostream::stream' only by return type or calling convention
Правильно ли я понял этот параграф стандарта? и это очередной баг 6 студии.
Знающие не говорят, говорящие не знают. Лао Цзы
Здравствуйте, ssi, Вы писали:
ssi>Правильно ли я понял этот параграф стандарта? и это очередной баг 6 студии.
VC6 эту фичу не поддерживает по причине своей древности.
... << RSDN@Home 1.1.0 stable >>