InstancePool
클래스 (그 중 일부)는 Instance.h 헤더가 포함되어 있지만 의 operator>>
함수 제목에 오류가 있습니다.`operator >> '는 Instance'의 구성원이 아닙니다
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <stdlib.h>
using namespace std;
#include "Instance.h"
#include "InstancePool.h"
istream &operator >> (istream &in , InstancePool &ip) {
ip.Instances->clear();
string input;
getline(in , input);
while (!in.eof()) {
Instance inst;
Instance::operator >>(in , inst); // <- line giving me the error
ip.Instances->push_back(inst);
getline(in , input);
}
}
InstancePool 연산자 >> 함수는 BTW이므로 인스턴스에는 동일한 함수가 있습니다. 아마도 나는 Instance 'operator >>에 잘못된 방법으로 접근하려고 노력하고 있습니다. 그러나 내가 올바른 것을 안다면 저주받을 것입니다 ... 도움이 되었습니까?
네, eof()를 사용하면 정말 나쁜 결과가 될 것이라고 생각했습니다. 나는 iput 스트림에서 직접 읽어야한다고 생각합니다. 제안 사항? 시간 내 주셔서 감사합니다! – user2055832
@ user2055832 네, 루프에서 직접 읽어보십시오 :'Instance inst; while (in >> inst) ip.Instances-> push_back (inst);는 객체가 개별적으로 읽히는 방식에 따라 작동 할 수 있습니다. –
흠. 나는 그런 식으로 시도하고 문제가 생겼을 때 다시보고 할 것입니다! 고맙습니다! – user2055832