istream eof の使用は「バグ」であり、コードを記述する「正式な」方法ではないことを読んだので、使用するより良いコードは何ですか? たとえば、次のコードがあります。
using namespace std; //I've heard this is bad practice also
int main(){
string line;
ifstream myfile("example.txt");
while(!myfile.eof()){
getline(myfile, line);
}//while
//do something with line
}//main
!myfile.eof() を何に置き換える必要がありますか? ありがとう!