daniel.w.gelder@gmail.com wrote:[color=blue]
> Well, I can't seem to make a class from two bases just because they
> have the same virtual function, even though I'm specifying the exact
> function:
>
> struct A
> { virtual void Function(); }
> struct B
> { virtual void Function(); }
>
> struct C : A, B
> {
> virtual void Function()
> {
> A::Function();
> B::Function();
> }
> };
>
> I didnt know this was not kosher but it is a pickle. Any way around
> this?
>
> Thanks
> Dan
>[/color]
Hmm, this works for me.
Compiler: g++ (GCC) 3.3.4 (pre 3.3.5 20040809)
OS: Linux, SuSE Pro v9.2
// z.cpp
// to compile: g++ -o z z.cpp
// to execute: ./z
#include <iostream>
struct A
{
virtual void Function()
{
std::cout << "A.Function()" << std::endl;
}
};
struct B
{
virtual void Function()
{
std::cout << "B.Function()" << std::endl;
}
};
struct C : A, B
{
virtual void Function()
{
std::cout << "C.Function()" << std::endl;
A::Function();
B::Function();
}
};
int main()
{
C c;
c.Function();
return 0;
}
Regards,
Larry
--
Anti-spam address, change each 'X' to '.' to reply directly.