Я использовал эту функцию раньше, но просто скопировав и вставив ее в другой файл, она перестала работать. Единственное изменение заключается в том, что я добавил «использование пространства имен std».
В моей функции "ReadData ()" я получаю ошибку на getline (cin, data), что ни один экземпляр перегруженных функций не соответствует списку аргументов. Кроме того, я получаю сообщение об ошибке «data» в сообщении, говоря: «данные неоднозначны».
Предполагается, что функция считывает данные из текстового файла и сохраняет строку текста в данных для дальнейшей обработки. Эта функция работала именно так, как она есть, поэтому я просто не уверен.
#include <iostream>
#include "NvraArray.h"
#include "NvraRecord.h"
#include <vector>
#include <string>
#include <ctime>
using namespace std;
// Globals
string data; // Stores the line that getline is at
vector<string> rows; // Stores the rows of data
vector<int> recordNumbersSeen; // Holds records numbers that have been checked
string strWords[24]; // Holds the individual columns of data for processing
int rowCounter = 0; // Counts the rows of data coming in
// Prototypes
// Reads the data from cin into the "rows" vector
void ReadData();
// Checks the current row against the list of records already seen
bool isDuplicate(int recordID);
// Checks the current row for invalid data
bool isValidData();
// Splits the row into an array to process
void SplitRowIntoArray(std::string row);
int main(){
// For testing purposes
srand(time(NULL));
NvraArray array;
NvraRecord record;
system("pause");
return 0;
}
void ReadData(){
while(getline(cin,data)){
// if on the first row, do nothing and skip to the next.
if(rowCounter != 0){
rows.push_back(data);
}else{
rowCounter++;
}
}
rowCounter = 0;
}