inheritance question

class Base
{
public:
virtual bool foo(){ return false; }
void something
{
bool retVal = foo();
}
};

class A : public A_interface
{
public:
virtual bool foo(){ return true; }
};

class A_interface : public Base
{
public:
virtual bool foo() = 0;
};

I want retVal to equal true, am I setting this up correctly
Last edited on
As it stands, there is no way that could work because base and A are not related.
what do i have to do to make it work?
Er... well you'll need to be more specific. What you're trying to do doesn't make any sense conceptually, at least not from what I can see.

If you just want foo to return true, then call it with an A object. Or change return false; to return true; =P.
Given your code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Base
{
public: 
virtual bool foo(){ return false; }
void something
{
bool retVal = foo();
}
};

class A : public A_interface
{
public:
virtual bool foo(){ return true; }
};

class A_interface : public Base
{
public:
virtual bool foo() = 0;
};


A a; a.something should have a retVal == true.
Of course B b; b.something will have a retVal == false.

But if you would be more specific it'll help us in being more specific, too ;-).
Write down your code and your expected and actual results.
Then we'll be able to help you make the last two match or at least explain why they never can match and maybe provide another solution that'll emulate the effect.
Topic archived. No new replies allowed.