Cannot call member function without object. C++ -
I am creating a merge sort class which works in a vector, sorts it and returns it . It looks like:
class MergeSort {public: template & lt; Class T & gt; Static vector & lt; T & gt; Sort (vector & lt; T & gt; a) {if (a.size ()) & lt; = 1) {Return; } Other {// some code here (vector vector & lt; t & gt; left = sort (bytewake); // recursive call vector & lt; T & gt; right = sort (rightVec); // recursive call vector & Lt; T & gt; FinalVec; // This will be the last vector returned to FinalVec = Merge (left, right); // will merge and sort when all vectors // ^^^^^ FinalVec; } Private: Template & lt; class T & gt;; Vector & lt; T & gt; Merge (vector & lt; T & gt; left, vector & lt; T & gt; right) {// some code here last Return;}};
** FinalVec = m (Left, right);
The error I am getting is:
Error: The member can not be called the function 'std :: vector MergeSort: : Merge (std :: vector, std :: vector) with [T = int]) without the object finalVec = merge (left, right); //
I try to do my main:
vector gooz;
gooz.push_back (7);
gooz.push_back (5);
gooz.push_back (4);
gooz.push_back (3);
gooz.push_back (2);
gooz.push_back (1);
gooz = MergeSort :: sort of gooz;
// Or even an object MergeSort will not work;
Thanks!
Perhaps because you have
vector & lt; T & gt; Have been declared.
Merge as private (do not call vector
Fixed vector sort (vector A) Sort Inside
. Try calling sort by using an object or merge as a static
Comments
Post a Comment