Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Gregg Whitcomb
Thu, 18 May 1989 20:44
possible type conversion bug...
Author: Gregg Whitcomb
Date: Thu, 18 May 1989 20:44
Date: Thu, 18 May 1989 20:44
54 lines
1728 bytes
1728 bytes
version: g++ 1.35.0
config: vax (ultrix 3.0)
problem: compiler reports ambiguous type conversion when attempting
to pass a "String" to a member function of a subclass accepting
a "char*". The subclass's base class defines the same member function.
example:
#include <stream.h>
#include "String.h"
class z
{
void* v;
public:
void set(void* a) {v = a;}
void* get() {return v;}
};
class x : public z
{
public:
void set(char* a="") {z::set(new String(a));}
String get() {return *((String*)z::get());}
};
class y : public x // get rid of "public" to make it compile
{
public:
void set(char* a="") {x::set(a);}
String get() {return x::get();}
};
main()
{
y a;
a.set(String("hello, world"));
cout << a.get() << "\n";
}
% g++ -g sambtype.cc
In function int main ():
ambtype.cc:31: ambiguous type conversion requested for method `set'
by making class "x" members non-public, it works fine. Shouldn't
the declaration of the class "y" member override any possible confusion
with the member in class "x"? I believe that the problem is more involved
than this demonstrates since the real code which produced the bug was
not fixed by removing the "public" keyword.
-Gregg Whitcomb whitcomb@ic.berkeley.edu
possible type conversion bug...
Author: Michael Tiemann
Date: Tue, 23 May 1989 04:42
Date: Tue, 23 May 1989 04:42
3 lines
532 bytes
532 bytes
That was a bug. I fixed it. Michael
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads