##一、
首先,.clear()方法我第一次是在cin对象上使用的,cin.clear()是用来更改cin的状态标示符的,cin在接收到错误的输入的时候,会设置状态位good。如果good位不为1,则cin不接受输入,直接跳过。如果下次输入前状态位没有改变那么即使清除了缓冲区数据流也无法输入。所以清除缓冲区之前必须要cin.clear()。[1]
类比的话,我想stringstream流应该也是一样的功能。
但是stringstream流和cin流还是有不同的,stringstream流好像是一个文件,而且好像有自己的读写位置指针,stringstream流有str()成员,而cin无此成员;
#include<iostream>
#include<vector>
#include<sstream>
using namespace std;
int main()
{
string str;
while(getline(cin, str)){
//cout << cin.str() << endl; 错误,无此成员;
vector<int> v