{"id":1657,"date":"2022-08-30T15:18:21","date_gmt":"2022-08-30T15:18:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/i-want-to-return-a-function-of-vectorcompetition-but-is-told-that-competition-is-undeclared-and-that-i-am-using-undefined-class-stdvector-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:21","modified_gmt":"2022-08-30T15:18:21","slug":"i-want-to-return-a-function-of-vectorcompetition-but-is-told-that-competition-is-undeclared-and-that-i-am-using-undefined-class-stdvector-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/i-want-to-return-a-function-of-vectorcompetition-but-is-told-that-competition-is-undeclared-and-that-i-am-using-undefined-class-stdvector-collection-of-common-programming-errors\/","title":{"rendered":"I want to return a function of vector&lt;Competition&gt; but is told that Competition is undeclared and that I am using undefined class &#39;std::vector&#39;-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to build a vector using a function that I am calling vector CompPop() because I want to return the vector info which is a type vector below is my code for the function returning the vector and the header for my Competition class.<\/p>\n<p>I&#8217;m getting the following errors but I&#8217;m using Visual Studio and the error message are very basic, leaving me guessing as to what I am actually doing wrong. Any help would be appreciated!! (Sorry if this is a silly questions)<\/p>\n<p>-error C2065: &#8216;Competition&#8217; : undeclared identifier<\/p>\n<p>&#8216;CompPop&#8217; uses undefined class &#8216;std::vector&#8217;<\/p>\n<p>&#8216;Competition&#8217; : undeclared identifier<\/p>\n<p>error C2133: &#8216;info&#8217; : unknown size<\/p>\n<p>error C2512: &#8216;std::vector&#8217; : no appropriate default constructor available<\/p>\n<p>error C2065: &#8216;Competition&#8217; : undeclared identifier<\/p>\n<p>error C2146: syntax error : missing &#8216;;&#8217; before identifier &#8216;temp&#8217;<\/p>\n<p>error C3861: &#8216;temp&#8217;: identifier not found<\/p>\n<p>error C2678: binary &#8216;[&#8216; : no operator found which takes a left-hand operand of type &#8216;std::vector&#8217; (or there is no acceptable conversion)<\/p>\n<pre><code>    #pragma once\n\n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \"LogIn.h\"\n    #include \"Registration.h\"\n    #include \"Tree.h\"\n    #include \"PriorityQueue.h\"\n    #include \"Events.h\"\n    #include \"Competition.h\"\n    using namespace std;\n\n    vector CompPop()\n    {\n        ifstream myfile(\"Results.txt\");\n\n        string line, tcomp, tleader, tfollower, tevents, tplacement;\n        vector info;\n        istringstream instream;\n        if(myfile.is_open())\n        {\n         int i = 0; \/\/ finds first line\n         int n = 0; \/\/ current vector index\n         int space;\n         while(!myfile.eof())\n         {\n        getline(myfile,line);\n\n        if(line[i] == '*')\n        {\n            space = line.find_first_of(\" \");\n\n            tleader = line.substr(0+1, space);\n            tfollower = line.substr(space + 1, line.size());\n\n        }\n        else\n        {\n            if(line[i] == '-')\n            {\n                tcomp = line.substr(1, line.size());\n                Competition temp(tcomp, tleader, tfollower);\n                info[n] = temp;\n            }\n            else\n            {\n                if(!line.empty())\n                {\n                    line = line;\n\n                    space = line.find_first_of(\",\");\n                    tevents = line.substr(0, space);\n                    tplacement = line.substr(space + 2,     line.size());\n                    info[n].pushEvents(tevents,tplacement);\n                }\n                if(line.empty())\n                {\n                    n++;\n                }\n            }\n           }\n            }\n        }\n       else\n       {\n        cout<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:25:27. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am trying to build a vector using a function that I am calling vector CompPop() because I want to return the vector info which is a type vector below is my code for the function returning the vector and the header for my Competition class. I&#8217;m getting the following errors but I&#8217;m using Visual [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1657","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1657"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1657\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}