[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference pamsrc::objectbroker_development

Title:ObjectBroker Development - BEA Systems' CORBA
Notice:See note 2 for kit locations; note 4 for training
Moderator:RECV::GUMBELd
Created:Thu Dec 27 1990
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2482
Total number of notes:13057

2325.0. "Associate Object questions. (associated_object)" by LEMAN::DONALDSON (Froggisattva! Froggisattva!) Mon Sep 23 1996 07:42

T.RTitleUserPersonal
Name
DateLines
2325.1The casting was needed on some platformsSEND::VLATASWARNING: Do not swallow the battery doorTue Sep 24 1996 09:5592
2325.2LEMAN::DONALDSONFroggisattva! Froggisattva!Mon Sep 30 1996 03:4431
2325.3VAXCPU::michaudJeff Michaud - ObjectBrokerWed Apr 02 1997 22:5729
> 	- what is the meaning/purpose of the double type-casting
> 	  used twice in the documentation (section 5.10.18.1, for example)
> 	  like this:
> 
> 		MYCLASS () : MYSERVER((void *)(MYSERVER *) this) {};

	Keep in mind that in C++, when one class is derived from another,
	the pointers value may change when cast (either explicitly or
	implicitly) between the two classes.  The compiler knows how much
	to adjust the pointer by.  However once you've cast a pointer to
	the void pointer, the compiler can no longer do this, it's up to
	the programmer to make sure that when they cast the void pointer
	back into a pointer to a class, that they cast it back to a pointer
	to the same exact class that it really is a pointer to.

	For example (and I believe a similiar example is in the ARM):

		class A {int x;};
		class B : A {int y;};

		B b;
		void *pv = (void *)&b;
		A *pA = (A *)pv;

	the above code is not portable.  pA may or may not be set correctly
	depending on the implementation of the compiler.  For the above
	to be portable you need a double cast such as:

		A *pA = (A *)(B *)pv;