![]() |
![]() |
![]() |
![]() |
![]() |
|
Another approach to the excessive-reclamation problem is to convert the parameter from a call-by-value parameter to a call-by-reference parameter. Then, no copy is made; no copy memory is reclaimed; and the destructor is never called:
Memory reserved for Memory reserved for r,
railroad_car argument the railroad_car parameter
| |
| *-------------------------------------*
v v
*-----*
| |
|-----|
| |
|-----|
| | ----*
|-----| |
| | |
| |
v
*---*---*---*---*---*---*---*---*---*
| | | | | | | | | |
*---*---*---*---*---*---*---*---*---*