文字列を整数に変換しているときに、istringstream をクリアして別の数値に配置することに失敗しました。あらゆる種類のさまざまなソリューションを試しましたが、うまくいきません。いくつかの回避策がありますが、その理由を知りたいのですが...
だから基本的にこれは私のコードがどのように見えるかです
#include <iostream>
#include <string>
#include <sstream>
int main() {
std::string a = "153";
std::string c = "2556";
int b;
std::istringstream convert(a);
convert >> b;
std::cout << b << std::endl;
convert.str( std::string() );
//convert.str("");
convert.clear();
convert(c);
convert >> b;
std::cout << b << std::endl;
return 0;
}
そして、次の出力エラー
C:\...\string to int.cpp|28|error: no match for call to '(std::istringstream {aka std::basic_istringstream<char>}) (std::string&)'|
ありがとう :)