次のコードがあります。
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
string inp, s;
istringstream iss;
do
{
getline (cin, inp);
iss(inp);
int a = 0, b = 0; float c = 0;
iss >> s >> a >> b >> c;
cout << s << " " << a << " " << b << " " << c << endl;
}
while (s != "exit");
}
次のエラーが生成されます。
error: no match for call to ‘(std::istringstream) (std::string&)’
ループ内で使用することで問題が回避される可能性があることはわかっていistringstream iss(inp);
ますが、この定義をループの外に移動することはできませんか?
(もちろん、それを移動することは可能ですが、私には何も達成できません。)