-1
とのgetlineを使用して、私が過負荷にオペレータと機能at()
とstring
の独自のクラスを作成します。私は別のクラスでそれを埋め込むためにそれを作成しました。私は1つを除いて何の問題もない。申し訳ありませんが自分のクラスC++
私のエラーは、次のとおりです。
std::basic_istream<_Elem,_Traits>&std::getline(std::basic_istream<_Elem,_Traits>&,std::basic_string<_Elem,_Traits,_Alloc> &)': could not deduce template argument for 'std::basic_string<_Elem,_Traits,_Alloc> &' from 'String'
問題がgetline()
機能です。この機能は、私がMY string
を使用して、私のファイルを読み込むためのgetline()
に別近いバリアントを見つけ引数str
.CanとしてMY string
を取ることはありませんか?
なぜMY文字列でgetline()
仕事、なぜそれがいくつかの実際の文字列を待たないことができませんか?
My機能は次のとおりです。
void City::readRecordings(char *fileName, char *num, std::vector<string> lines)
{
string str;
//std::ifstream fin(fileName);
readRecord >>str;
int readCount = 0;
int n = atoi(num);
readRecord.open(fileName);
while (!readRecord.eof())
{
std::getline(readRecord, str);/*here is Error, It can't use my String str , it waits for usual string*/
readCount++;
lines.push_back(str);
}
if (0 == readCount)
{
std::cout << "ERROR: The file, which you are trying to open, is empty or it stops out" << end;
exit(-1);
}
if (n > readCount)
{
std::cout << "!Warning!" << end;
std::cout << "You want to read " << n << " recordings" << " But AVAILABLE: " << readCount << " recordings" << end;
printRecordsFromFile(readCount, lines);
}
else
{
printRecordsFromFile(n, lines);
}
}
それは空が青いのと同じ理由です: 'のstd :: getlineの()'の2番目のパラメータは 'のstd :: STRING'あるので(まあ、'のstd :: basic_string'は、知識をひけらかすこと)。それはどのような 'のstd :: getlineの()'であるのです。 –
だから_fromだ何String'_はエラーメッセージで述べました。あなた自身のもの? –
@πάνταῥεῖはい、私は私の文字列のために実現しました –