Inheritance issue.

I have two very different interfaces, A and B that have a single pure virtual function in common. Some objects are inheriting from both A and B. The problem is A is usually inherited a level above B and its pure virtual is defined there, meaning on the object which inherits B cannot find the definition.

Is there a way to 'show' B that the function is defined just not within its current scope?

IE:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class A{
public:
	virtual int Get() = 0;
};

class B{
public:
	virtual int Get() = 0;
};

class C : public A{
public:
	C(){ _c = 5; }
	virtual int Get(){ return _c; }
protected:
	int _c;
};

class D public C, public A{
	// what would go here to show B that C::Get() is defined?
};

int main()
{
	D test;
	return 0;
};

I'm assuming 'D' was supposed to inherit from C and B (not from C and A)

Anyway you can do this:

1
2
3
class D : public C, public B{
    virtual int Get() { return C::Get(); }
};
Yep that works, thanks again!
Topic archived. No new replies allowed.