B
brentritchie
Hello everyone,
I have this problem, I want to declare an interface class and have
it inherit from other interfaces. But when I define a concrete class I
want to substitute implementations of interfaces instead of the
interfaces themselves; In much the same way I can use a refrence to an
interface within a class but point to any object that implements that
interface.To illustrate:
class AInterface
{
public:
virtual char* something()=0;
}
class AImplementation
{
public:
char* something(){return "doing something...";};
}
class BInterface : public AInterface
{
}
Now the problem is, how do I inherit from BInterface but use
AImplementation instead of AInterface? I looked at late binding and
runtime inheritence but they don't seem to be what I want. Any pointers
to what I want to do?
The reason I don't want to just use concrete classes is that I don't
want to build a new set of classes every time I change platforms or
other external parts of my program. I'll just have to do
implementation\platform specific code on a few interfaces instead.
Thanks to all that apply.
p.s. I also posted this to comp.std.c++ but I did not cross post
because I don't think it's polite to cross post to a moderated and
unmoderated group.
I have this problem, I want to declare an interface class and have
it inherit from other interfaces. But when I define a concrete class I
want to substitute implementations of interfaces instead of the
interfaces themselves; In much the same way I can use a refrence to an
interface within a class but point to any object that implements that
interface.To illustrate:
class AInterface
{
public:
virtual char* something()=0;
}
class AImplementation
{
public:
char* something(){return "doing something...";};
}
class BInterface : public AInterface
{
}
Now the problem is, how do I inherit from BInterface but use
AImplementation instead of AInterface? I looked at late binding and
runtime inheritence but they don't seem to be what I want. Any pointers
to what I want to do?
The reason I don't want to just use concrete classes is that I don't
want to build a new set of classes every time I change platforms or
other external parts of my program. I'll just have to do
implementation\platform specific code on a few interfaces instead.
Thanks to all that apply.
p.s. I also posted this to comp.std.c++ but I did not cross post
because I don't think it's polite to cross post to a moderated and
unmoderated group.