call to super trashes pointer?
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 23 01:20:00 PST 2016
On Tuesday, 23 February 2016 at 09:16:08 UTC, Nicholas Wilson
wrote:
> struct A
> {
> int blah;
> }
> class B
> {
> A* a;
> this(A* _a)
> {
> writeln(_a)
> a =_a;
> }
> }
>
> class C : B
> {
> this(A* _a)
> {
> writeln(_a)
> super(_a);
> }
> }
> int main(string[] args)
> {
> A a;
> writeln(&a);
> C c = new C(&a);
> }
>
> prints
> 7FFF56E787F8
> 7FFF56E787F8
> null
>
> ??? What is happening here?
fwiw I can reassign the reference (in the classes) to a after B's
call to super but still ...
More information about the Digitalmars-d-learn
mailing list