inheritance and memory layout

  • Thread starter Anargyros L. Papadopoulos
  • Start date
A

Anargyros L. Papadopoulos

given:
class A {
// ...
};

class B : public class A {
// ...
}

void some_fun()
{
B b;
A *pa = &b;
B *pb = &b;

if ((void *)pa == (void *)pb) {
;
} else {
// is it possible ??
;
}
}

is it guarantee (from the standard), assuming single inheritance, that it is
impossible to reach the else statement in the above code?
 
R

rajkumar

The said link just presents one way of implementing virtual functions.
I dont think standard says anything about how to implement virtual
functions.

The OP had asked in case of singled inheritance if else branch can be
true.

I think it can be if the user overloads & operator for B and does
something crazy

raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top