我正在使用“cin >> my_char”在我试图解析的输入记录中放置一个“:”。这是一个最小的例子。
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main () {
char c;
int x, y;
cin >> hex >> x >> hex >> c >> y;
cout << "x = " << x << "\ny = " << y << "\n";
}
和示例用法:
rc@timecube:/tmp$ g++ test.cpp && echo "0000a:ffff" | ./a.out
x = 10
y = 65535
这段代码完全符合我的要求,但我不明白为什么。我希望看到类似的内容:
istream& operator>> (char& val);
在 istream 引用 here ,但我没有。
那么这种行为是如何记录的呢?
最佳答案
并非所有运营商都是成员(member)!
关于c++ - "my_ifstream >> my_char"记录在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29610556/