错误"function call missing argument list" - 帮助为我指明正确的方向

Error "function call missing argument list" - Help point me in the right direction

本文关键字:方向 帮助 call function missing argument list 错误      更新时间:2023-10-16

背景:尝试编写一个简单的程序,使用字符串在超过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:programmingcomma_placing_in_numberscomma_placing_in_numberscomma_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:programmingcomma_placing_in_numberscomma_placing_in_numberscomma_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

编译器解释得很好。

value.insert(value.begin+1,',');

begin是一个函数。它需要一个带括号的列表符号()来调用