I want to return a function of vector<Competition> but is told that Competition is undeclared and that I am using undefined class 'std::vector'-Collection of common programming errors
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’m getting the following errors but I’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)
-error C2065: ‘Competition’ : undeclared identifier
‘CompPop’ uses undefined class ‘std::vector’
‘Competition’ : undeclared identifier
error C2133: ‘info’ : unknown size
error C2512: ‘std::vector’ : no appropriate default constructor available
error C2065: ‘Competition’ : undeclared identifier
error C2146: syntax error : missing ‘;’ before identifier ‘temp’
error C3861: ‘temp’: identifier not found
error C2678: binary ‘[‘ : no operator found which takes a left-hand operand of type ‘std::vector’ (or there is no acceptable conversion)
#pragma once
#include
#include
#include
#include
#include
#include "LogIn.h"
#include "Registration.h"
#include "Tree.h"
#include "PriorityQueue.h"
#include "Events.h"
#include "Competition.h"
using namespace std;
vector CompPop()
{
ifstream myfile("Results.txt");
string line, tcomp, tleader, tfollower, tevents, tplacement;
vector info;
istringstream instream;
if(myfile.is_open())
{
int i = 0; // finds first line
int n = 0; // current vector index
int space;
while(!myfile.eof())
{
getline(myfile,line);
if(line[i] == '*')
{
space = line.find_first_of(" ");
tleader = line.substr(0+1, space);
tfollower = line.substr(space + 1, line.size());
}
else
{
if(line[i] == '-')
{
tcomp = line.substr(1, line.size());
Competition temp(tcomp, tleader, tfollower);
info[n] = temp;
}
else
{
if(!line.empty())
{
line = line;
space = line.find_first_of(",");
tevents = line.substr(0, space);
tplacement = line.substr(space + 2, line.size());
info[n].pushEvents(tevents,tplacement);
}
if(line.empty())
{
n++;
}
}
}
}
}
else
{
cout
Originally posted 2013-11-27 12:25:27.