背景:試圖編寫一個簡單的程序,使用字符串在999以上的數字中添加逗號。錯誤「函數調用缺少參數列表」 - 幫助指向正確的方向
編譯:的Visual Studio 2012
問題:我不明白是什麼錯誤意味着,我不知道在哪裏可以搜索找到一個答案(我的一切都在網上找到已經具體到使用的代碼)
結果:錯誤的解釋是試圖告訴我或一個主題或領域來研究請。
代碼:
#include "stdafx.h"
#include <string>
#include "string.h"
#include <iostream>
#include <stdlib.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string value="1000";
int size = value.size();
switch (size) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
value.resize(size+1);
value.insert(value.begin+1,',');
break;
default:
cout << "I dont know how i got here??" << endl;
break;
} // end of switch
return 0;
}
結果:
1>i:\programming\comma_placing_in_numbers\comma_placing_in_numbers\comma_placing_in_numbers.cpp(29): error C3867: 'std::basic_string<_Elem,_Traits,_Alloc>::begin': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Alloc>::begin' to create a pointer to member
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1>i:\programming\comma_placing_in_numbers\comma_placing_in_numbers\comma_placing_in_numbers.cpp(29): error C2664: 'std::basic_string<_Elem,_Traits,_Alloc> &std::basic_string<_Elem,_Traits,_Alloc>::insert(unsigned int,const std::basic_string<_Elem,_Traits,_Alloc> &)' : cannot convert parameter 2 from 'char' to 'const std::basic_string<_Elem,_Traits,_Alloc> &'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> Reason: cannot convert from 'char' to 'const std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
此外,這是編譯器的響應 – user3474943
編譯器錯誤:http://pastebin.com/59kNWybk – user3474943
begin是一個函數。嘗試value.begin() – PlayDeezGames