错误"function call missing argument list" - 帮助为我指明正确的方向
Error "function call missing argument list" - Help point me in the right direction
背景:尝试编写一个简单的程序,使用字符串在超过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
是一个函数。它需要一个带括号的列表符号()
来调用
相关文章:
- 使用Unreal C++获取VR耳机的世界位置/方向
- 需要帮助设置在C++中使用的Potrace
- 在指针的帮助下,文本文件中单词的频率
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 需要帮助将结构数组传递给函数
- 在C++中向零方向近似的最佳方法
- 垂直方向的 Gtk3+ 旋转按钮 (c/c++)
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- OpenVR:向视图方向移动
- 需要帮助在 c++ 中将字符串转换为字符 ----错误 "const char *" 类型的值不能用于初始化 "char" 类型的实体
- 有人可以帮助我处理正则表达式吗?
- C++调用具有 *this 属性的单个帮助程序函数
- C++:需要帮助了解运算符重载错误
- 需要以下代码的帮助,下面的代码有什么问题
- CS1 项目帮助C++
- 用于检查值是否为其任何参数的帮助程序函数
- 需要有关此 if 语句的帮助
- 类型限定宏帮助程序
- 错误"function call missing argument list" - 帮助为我指明正确的方向