Is this piece of C++ considered okay in terms of memory management?
<p>I am kind of getting bogged down by the concept of memory management (all my previous programming languages doesn't need me to manage the memory). I'm not sure if creating a variable will consume memory if I don't destroy it later.</p>

<pre><code>#include &lt;math.h&gt;
#include &lt;iostream&gt;
using namespace std;

double sumInfiniteSeries(double u1, double r){
 return u1 / (1 - r);
}

double sumInfiniteSeries(double u1, double r, bool printSteps){
 if (printSteps){
  double lastTotal;
  double total = 0.0;
  double sn = u1;
  for (int n=1;n&lt;=1000;n++){
   lastTotal = total;
   total += sn;
   sn *= r;
   cout &lt;&lt;  "n = " &lt;&lt; n &lt;&lt; ": " &lt;&lt; total &lt;&lt; endl;
   if (fabs(lastTotal - total) &lt; 0.000000000000001) return total;
  }
  return total;
 } else {
  return sumInfiniteSeries(u1, r);
 }
}
</code></pre>

<p>Do i need to "destroy" any variables in these 2 functions?</p>

<p>Edit: So when I create my own class and its instance would I need to start memory management?</p>
