++私は、このプログラムがあります。C++、に 'CHAR' から無効な変換 'のconstのchar *'
#include <iostream>
using namespace std;
int main(){
string expression_input;
cout << "User Input: " << endl;
getline(cin, expression_input);
expression_input.insert(0, '('); //error happens here.
expression_input.append(')');
}
を私は次のエラーを取得しています:
私は変換アムprog.cpp:15: error: invalid conversion from ‘char’ to ‘const char*’
prog.cpp:15: error: initializing argument 2 of
‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT,
_Traits, _Alloc>::insert(typename _Alloc::rebind<_CharT>::other::size_type,
const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>,
_Alloc = std::allocator<char>]’
char
〜const char*
?文字列の位置0に文字を挿入できませんか?
-1:ほとんどの場合、 'insert'を' char'で使うことができます。あなたはちょうどそれの異なる過負荷を使用する必要があります。 –
私はそれが使用して署名を使用する文字列::挿入関数では動作しませんが言及に失敗したと思います – minus