저는 이번에는 더 많은 설명을하려고 노력할 것입니다. 저는 연구를 해왔지만 그것을 이해하지 못하는 것 같습니다. I는 다음과 같습니다 클래스라는 시간을 가지고 : 두 번째 숫자는 각 라인의 첫 번째 숫자는 times[i].hours
입니다한 줄의 파일을 한 객체의 두 변수로 읽어들입니다.
90 1 3.0
1 1 100.0
2 34 5.1
:
class Time{
private:
int minutes;
int hours;
public:
Time();
Time(int h, int m);
void addMin(int m);
void addHour(int h);
void setTime(int m, int h);
void reset(int h=0, int =0);
Time sum(const Time &t) const; //Add one time to another time.
Time sum(int m) const;
Time operator*(double other) const;
void show() const;
};
나는이처럼 보이는 파일이 times[i].minutes
이고, 세 번째 값은 math[i]
에 저장 될 double 값입니다. 변수가 private이기 때문에 'setTimeHours (int h)'를 호출해야하고 setTimeMinutes(int m)
을 호출해야하며 어떻게해야하는지 잘 모르겠습니다. 이것이 내가 가진 것입니다.
int number_of_lines = 0;
std::string line;
while (std::getline(inputFile, line)){
++number_of_lines;
}
Time times[number_of_lines];
double math[number_of_lines];
std::string input;
for(int loop=0;loop<number_of_lines;loop++){
std::getline(inputFile, input);
stid::istringstream(input) >> times[i].minutes >> times[i].hours >> math[i];
}
내가 도움이 필요 라인은 다음과 같습니다
stid::istringstream(input) >> times[i].setTimeMinutes(//what goes here?) >> times[i].setTimeHours(//what goes here?) >> math[i];
물론 심지어 일을 거 야, 경우? 감사!
나는 이것도 시험해 볼 것이다, 정말로 고마워! – user2990286