Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > inheritance and memory layout

Reply
Thread Tools

inheritance and memory layout

 
 
Anargyros L. Papadopoulos
Guest
Posts: n/a
 
      03-08-2005
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?


 
Reply With Quote
 
 
 
 
EventHelix.com
Guest
Posts: n/a
 
      03-08-2005
With single inheritance, yes it is impossible to reach the else
statement.

The following article should help:

http://www.eventhelix.com/RealtimeMa...rformance2.htm

Deepa
--
EventStudio 2.5 - http://www.EventHelix.com/EventStudio
Generate Sequence diagrams from a simple declarative language

 
Reply With Quote
 
 
 
 
rajkumar@hotmail.com
Guest
Posts: n/a
 
      03-08-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory Layout for Multiple and Virtual Inheritance Ge Chunyuan C++ 0 07-23-2007 01:23 AM
Memory layout of an object with multiple inheritance stasgrom@gmail.com C++ 1 10-08-2006 01:46 PM
Choosing Layout: Css-Layout or Table-Layout hpourfard@gmail.com ASP .Net 1 06-19-2006 10:06 AM
Article about memory layout for virtual inheritance Edsko de Vries C++ 0 01-09-2006 02:36 PM
DataList inside a Grid Layout Panel (<DIV>) item layout problem Rick Spiewak ASP .Net 3 08-26-2003 04:22 AM



Advertisments