Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable or field 'psort' declared void
    text
    copied!<p>I'm getting this error when I try to compile:</p> <pre><code>psort.cpp:11:17: error: variable or field ‘psort’ declared void void psort(std::vector&lt;T&gt; * array) </code></pre> <p>I'm not really sure why I'm getting this. I read through a few other posts about the same error but they didn't really help me at all.</p> <pre><code>/** * @file psort.h */ #ifndef _PSORT_H_ #define _PSORT_H_ #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;omp.h&gt; using std::vector; namespace ParallelSort { /** * Public wrapper for the parallel sort implementation. * @param array The structure to sort */ template &lt;class T&gt; void psort(vector&lt;T&gt; * array); template &lt;class T&gt; vector&lt;T&gt; * mergeSort(vector&lt;T&gt; * array, int left, int right); template &lt;class T&gt; vector&lt;T&gt; * merge(vector&lt;T&gt; * arr1, vector&lt;T&gt; * arr2); } #include "psort.cpp" #endif </code></pre> <p>and here's the .cpp :</p> <pre><code>template &lt;class T&gt; void psort(vector&lt;T&gt; * array) { mergeSort(array, 0, array-&gt;size() - 1); } template &lt;class T&gt; vector&lt;T&gt; * mergeSort(vector&lt;T&gt; * array, int left, int right) { if (left &gt;= right) { return array; } int midpoint = (left + right) / 2; return merge(mergeSort(array, left, midpoint - 1), mergeSort(array, midpoint, right)); } template &lt;class T&gt; vector&lt;T&gt; * merge(vector&lt;T&gt; * arr1, vector&lt;T&gt; * arr2) { vector&lt;T&gt; * result(); result-&gt;resize(arr1-&gt;size() + arr2-&gt;size()); int i = 0; // result array position int j = 0; // arr1 position int k = 0; // arr2 position while (i &lt;result-&gt;size() ) { if (j &gt;= arr1-&gt;size()) { result[i] = arr2[k]; i++; k++; } else if (k &gt;= arr2-&gt;size()) { result[i] = arr1[j]; i++; j++; } else if (arr1[j] &lt;= arr2[k]) { result[i] = arr1[j]; i++; j++; } else if (arr2[k] &lt;= arr1[j]) { result[i] = arr2[k]; i++; k++; } } return result; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload