c++ - 为什么我在使用 getline() 时遇到问题?“没有重载函数的实例与参数列表匹配”和“数据不明确”
问题描述
我以前使用过这个确切的功能,但简单地将其复制并粘贴到另一个文件会导致它停止工作。唯一的变化是我添加了“使用命名空间标准”。
在我的“ReadData()”函数中,我在 getline(cin, 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;
}