Can someone tell me why the following code doesn't work:
[color=blue]
> TestClass.cpp
> -------------
> class A
> {
> public:
> virtual void read(wchar_t& ch) { read(&ch, 0, 1); }
> virtual void read(wchar_t* buf, int off, int len) = 0;
> };
>
> class B : public virtual A
> {
> public:
> virtual void read(wchar_t* buf, int off, int len) {}
> };
>
> int main(int argc, char* argv[])
> {
> wchar_t ch;
> B myclass;
> myclass.read(ch );
> }[/color]
I have tried both gcc 2.96 and gcc 3.2. I get:
[color=blue]
> TestClass.cpp: In function `int main(int, char**)':
> TestClass.cpp:2 1: no matching function for call to `B::read(wchar_ t&)'
> TestClass.cpp:1 4: candidates are: virtual void B::read(wchar_t *, int, int)[/color]
Shouldn't B have inherited read(wchar_t& ch) from A?
[color=blue]
> TestClass.cpp
> -------------
> class A
> {
> public:
> virtual void read(wchar_t& ch) { read(&ch, 0, 1); }
> virtual void read(wchar_t* buf, int off, int len) = 0;
> };
>
> class B : public virtual A
> {
> public:
> virtual void read(wchar_t* buf, int off, int len) {}
> };
>
> int main(int argc, char* argv[])
> {
> wchar_t ch;
> B myclass;
> myclass.read(ch );
> }[/color]
I have tried both gcc 2.96 and gcc 3.2. I get:
[color=blue]
> TestClass.cpp: In function `int main(int, char**)':
> TestClass.cpp:2 1: no matching function for call to `B::read(wchar_ t&)'
> TestClass.cpp:1 4: candidates are: virtual void B::read(wchar_t *, int, int)[/color]
Shouldn't B have inherited read(wchar_t& ch) from A?
Comment