Thread View: comp.std.c++
1 messages
1 total messages
Started by Jeff Anton
Tue, 12 Sep 1995 22:33
standard conversions applied after user-defined conversions ???
Author: Jeff Anton
Date: Tue, 12 Sep 1995 22:33
Date: Tue, 12 Sep 1995 22:33
61 lines
2092 bytes
2092 bytes
In the following code, it seems to me that over.best.ics should allow
the following call to func(...) however no compiler I've found supports this.
It's possible that dcl.init.ref is the section which disallows this,
but it's very hard to tell. I know this could be abused or mislead
but it is also valuable and I can not find a good syntactic work around
other than explict construction of the argument.
The reason to do this is that I would like to have an abstract base
class which is passed to library routines, but I want the object that
supports that interface(abstract base class) to be implictly constructed
in the caller. This way the library can be built with only the
abstract base class in scope and the calling module can 'own' the real
object implementation.
The standard conversion sequence should include base class conversion
and qualification adjustment, but it seems that the base class conversion
is not considered after a user-defined conversion.
Is this a bad approach? Am I missing a viable way to do this? Is this
a hole in the draft?
class A {
public:
virtual ~A() {};
virtual int f() = 0;
};
void func(const A &)
{
}
class B : public A
{
public:
B(int);
virtual ~B();
virtual int f();
};
int
B::f()
{
return 0;
}
int
main()
{
func(2);
return 0;
}
Jeff Anton
anton@illustra.com
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
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