I just found this nice example.
http://pastebin.com/4QV5k0ev
Even though it works and i see the code in front of me i don't understand how this works.
The output is:
A::f 60
B::f 55 b2
B::f 44 b1
A::f 30
A::f 20
A::f 10
So it is the reversed order of the objects that have been created.
code line 15 is where the "magic" happens.
the list of A objects is static (so all created objects share the same list)
but every time a object is created the next pointer points to the list, which points to " this" (the just created object)...so how i understand this is
that the list-pointer is every time overwritten by the actual object coz the pointer is never incremented.
->
A::f 60
and the next strange thing is the void A::printList() function in line 23. I don't get this at all ^^
Can somebody explain me how this works ?