Corrected errors in the "memory management" section.
Thanks to ZhangQian for pointing them out
This commit is contained in:
parent
3276d502ea
commit
fe9de42802
1 changed files with 6 additions and 6 deletions
|
|
@ -430,9 +430,9 @@ function.
|
|||
which gives something like
|
||||
<p><b><tt><font color="#993300">eoTournamentSelection<EOT> *ptSelect
|
||||
= new eoTournamentSelection<EOT>(tSize);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoBreeder<EOT> *ptBreed = new eoBreeder<EOT>(select);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoBreeder<EOT> *ptBreed = new eoBreeder<EOT>(*ptSselect);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoEasyAlgo<EOT> *ptAlgo = new eoEasyAlgo<EOT>(
|
||||
..., breed, ...);</font></tt></b>
|
||||
..., *ptBreed, ...);</font></tt></b>
|
||||
<p>and you can then use the dynamically allocated objects anywhere. But
|
||||
the trouble with such a construct is that after exiting the function where
|
||||
such objects are defined, <b><font color="#FF6600">you will never be able
|
||||
|
|
@ -451,10 +451,10 @@ to care of.
|
|||
<p><b><tt><font color="#993300">eoTournamentSelection<EOT> *ptSelect
|
||||
= new eoTournamentSelection<EOT>(tSize);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">state.storeFunctor(ptSelect);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoBreeder<EOT> *ptBreed = new eoBreeder<EOT>(select);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoBreeder<EOT> *ptBreed = new eoBreeder<EOT>(*ptSelect);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">state.storeFunctor(ptBreed);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoEasyAlgo<EOT> *ptAlgo = new eoEasyAlgo<EOT>(
|
||||
..., breed, ...);</font></tt></b>
|
||||
..., *ptBreed, ...);</font></tt></b>
|
||||
<br><b><tt><font color="#993300">state.storeFunctor(ptAlgo);</font></tt></b>
|
||||
<p>or, even more quickly (though less readably)
|
||||
<p><b><tt><font color="#993300">eoTournamentSelection<EOT> *ptSelect
|
||||
|
|
@ -463,10 +463,10 @@ to care of.
|
|||
state.storeFunctor(new eoTournamentSelection<EOT>(tSize));</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoBreeder<EOT> *ptBreed =</font></tt></b>
|
||||
<br><b><tt><font color="#993300">
|
||||
state.storeFunctor(new eoBreeder<EOT>(select));</font></tt></b>
|
||||
state.storeFunctor(new eoBreeder<EOT>(*ptSelect));</font></tt></b>
|
||||
<br><b><tt><font color="#993300">eoEasyAlgo<EOT> *ptAlgo =</font></tt></b>
|
||||
<br><b><tt><font color="#993300">
|
||||
state.storeFunctor(new eoEasyAlgo<EOT>( ..., breed, ...));</font></tt></b>
|
||||
state.storeFunctor(new eoEasyAlgo<EOT>( ..., *ptBreed, ...));</font></tt></b>
|
||||
<p>In both the above code, state is an <b><tt><font color="#993300"><font size=+1>eoFunctorStore</font></font></tt></b>
|
||||
that is of course <b><font color="#FF6600">passed from outside the function</font></b>
|
||||
- and it's called state because in most cases it will actually be an eoState.
|
||||
|
|
|
|||
Reference in a new issue