Anonymous objects

Hello,
I'm new on this forum and currently writing a thesis on traffic simulation.

For this thesis I'm writing a simulation program which is triggered by events ordered in a double linked list.

I'm creating new events at a source with randomized intervals.

I add those to the linked list in a way like this:

source.random_source_event().push_into_linkedlist(pointer_to_first_event);

Now my problem is that the anonymous object created here is deleted every time the simulation loop is repeated.

Is there any way to create anonymous objects that are not deleted, because naming them would be quite some work and make the logic more complicated?

Thanks in advance,
Jurrian

To get it clear some simplified code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
main{

time =0;

while(time<MAX_TIME){
time=(*agenda).time;

switch (agenda.action_type){

case ENTRY:
     source.random_source_event().push_into_linkedlist(agenda);
break;

*other cases*

}}



}
If you want the same variable to be used for each loop iteration, just define it outside the loop.

I'm not sure what you are getting at with anonymous objects - how are you intending them to help you here?
Last edited on
Topic archived. No new replies allowed.