umber">3.1</span> Writing your Rcpp code</h2>
<p>The below code defines a function <code>rcpp_sum()</code> that calculates the sum of a vector. Save this content as a file named “sum.cpp”.</p>
<p><strong>sum.cpp</strong></p>
<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb3-1"><a href="030_basic_usage.html#cb3-1"></a><span class="co">//sum.cpp</span></span>
<span id="cb3-2"><a href="030_basic_usage.html#cb3-2"></a><span class="pp">#include </span><sp