Re: Two pointers to the same obejct, two differnet values...
From: Alf P. Steinbach (alfps_at_start.no)
Date: 12/18/03
- Next message: CoolPint: "Help Please: Finding out the Iterator to the Child node in binary heap"
- Previous message: Jeff Schwab: "Re: difficulties with sprintf function"
- In reply to: Mattias Brändström: "Two pointers to the same obejct, two differnet values..."
- Next in thread: Gianni Mariani: "Re: Two pointers to the same obejct, two differnet values..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 18 Dec 2003 14:36:27 GMT
On Thu, 18 Dec 2003 15:16:21 +0100, =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?= <brasse@ludd.luth.se> wrote:
>class A {
>public:
> virtual void foo(int i) = 0;
>};
>
>class B {
>public:
> virtual void bar(int i) = 0;
>};
>
>class AB : public A, public B {
>public:
> void foo(int i) { }
> void bar(int i) { }
>};
>
>int main() {
>
> AB* ab = new AB();
>
> cout << ab << endl;
> cout << dynamic_cast<A*>(ab) << endl;
> cout << dynamic_cast<B*>(ab) << endl;
>
> return 0;
>}
>
>This gives me the output:
>
>0x8049d90
>0x8049d90
>0x8049d94
>
>The question is this: can I rely on this behaivour and expect to get
>differnt pointers on all platforms
No. A C++ implementation might not even use v-tables.
> or are there some platforms that
>might give me the same pointer no matter on how I look at an object?
There might be.
- Next message: CoolPint: "Help Please: Finding out the Iterator to the Child node in binary heap"
- Previous message: Jeff Schwab: "Re: difficulties with sprintf function"
- In reply to: Mattias Brändström: "Two pointers to the same obejct, two differnet values..."
- Next in thread: Gianni Mariani: "Re: Two pointers to the same obejct, two differnet values..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]