Could someone help me understand what is going to be returned in following piese of code and why (the processing logic) (I have no way to compile it by myself now....)

struct A {
    int value;
    virtual int access() { return this->value; }
};
struct B {
    int value;
    virtual int access() { return this->value; }
};
struct C : public A, public B {
    int better_value;
    virtual int access() { return this->better_value; }
};
 
int use(B *b)
{
    return b->access();
}
 
... C c; use(&c); ...

I am not clear by the call: use(&c) - the access() is used from the C class implementation or from the B class?
So, will it return the C::better_value or B::value?

And one more question:
If I try to set the c::value - what value it going to set: B::value or A::value, or I have to specify it explicitely: c::B::value or c::A::value?

Appreciate your help!

It looks like an exam or test question ;)

Okay, I would guess the same for such questons.. But, actually, I was reviewing the term 'thunk' example on http://en.wikipedia.org/wiki/Thunk I've used C++ but it is not current, so I could not recall what is going on...

Well, it does not matter what's use function returned value: you forgot to initialize your c object ;)...
Look at http://www.daniweb.com/forums/announcement8-2.html

Hmm.., not much usefull ansver.
I am not asking if this code completed or correct, but WHAT CLASS METHOD IS GOING TO BE USED!
If you are not sure, why to answer?
If you are clear in what is going to be processed why do not answer clear.
I will check your link, although if I would like to get reference to some reading, I would ask such..
But, thank you for appear, anyway

I see you don't understand basics of polymorphism in C++ (obviously, C::access was called). If so, why you are trying to understand a subtle virtual function optimization issues with wrapper functions generated by compiler?
As usually, the thunk term does not used in this area...

I see you don't understand basics of polymorphism in C++ (obviously, C::access was called). If so, why you are trying to understand a subtle virtual function optimization issues with wrapper functions generated by compiler?
As usually, the thunk term does not used in this area...

Thank you for answer
[off-top]
Why are you make some conclusions and trying to judge others?!
Quick judgment = low intellect
If on this forum such behavior is standatd - I do not need a such membership...
[\off-top]

Thank you for answer
[off-top]
Why are you make some conclusions and trying to judge others?!
Quick judgment = low intellect
If on this forum such behavior is standatd - I do not need a such membership...
[\off-top]

Well and I don't understand persons who ask homework level questions then make conclusions about my IQ...

This article has been dead for over six months. Start a new discussion instead.