473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inheritance and memory layout

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?
Jul 23 '05 #1
2 2263
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

Jul 23 '05 #2
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

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
12879
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
3
41510
by: enchantingdb | last post by:
I have an exam tomorrow that covers the perceived advantages and disadvantages of object oriented programming, in particular polymorphism, inheritance and encapsulation. I know the advantages but...
5
2039
by: Invalidlastname | last post by:
Hi, I just read the pattern "Design and Implementation Guidelines for Web Clients" from MSDN. Here is my question. In chapter 3,...
6
2084
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
0
1827
by: Edsko de Vries | last post by:
Hi, I wrote an article that may be of interest to some people in this newsgroup. It explains the memory (object) layout for multiple and virtual inheritance. The article can be read at ...
3
292
by: junw2000 | last post by:
Below is a simple code about multiple inheritance #include <iostream> class A{ int x; }; class B{ int y;
1
3162
by: stasgrom | last post by:
Guys, I have this situation: the class C is defined as follow: class C: public A, public B {...}; Now when I create an object of class C, I can see that the compiler (VS 8.0) decides to layout...
0
1413
by: Ge Chunyuan | last post by:
hi: Just out of curiosity, more than 10 years passed since Stanley B. Lippman's <<Inside the C++ Object Model>>. Is there anything changed these days? Eg, the "Memory Layout for Multiple...
3
1782
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all It is maybe a stupid question, but I have some trouble with Inheritance. For example: I create a new class with one form. On this form I place on the bottom a Panel and on this Panel...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.