Christoff,
I just noticed I wasn't really answering the real problem you report,
which is the crash.
I believe the problem is in your code: You create two vectors of
value-types (cars and factories). Then you take references to the stored
objects, while there is no guarantee that the objects' addresses won't
change over time. In particular, there is a good chance of these objects
to be copied as the vector gets resized as new objects are added beyond
their current capacity.
As a test, I called
vector<...>::reserve(32)
on each of the vectors right in the Factory and Manufacturer
constructors, with the effect of allocating enough storage upfront so
that in your sample code no re-allocation is required, and thus objects
won't be copied around. This prevents the crash from happening for me.
Obviously this is just to illustrate the problem; it's definitely not a
solution to your problem, which still is that you reference objects
beyond their lifetime.
HTH,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
_______________________________________________
Cplusplus-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/cplusplus-sig