Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ “错误”;函数调用缺少参数列表";-帮我指出正确的方向_C++ - Fatal编程技术网

C++ “错误”;函数调用缺少参数列表";-帮我指出正确的方向

C++ “错误”;函数调用缺少参数列表";-帮我指出正确的方向,c++,C++,背景:尝试编写一个简单的程序,使用字符串在999以上的数字中添加逗号 编译器:Visual Studio 2012 问题:我不理解错误的含义,也不知道在哪里搜索以找到答案(我在网上找到的所有内容都是针对所提供的代码的) 结果:对错误的解释是试图告诉我或者一个要研究的主题或领域 代码: #include "stdafx.h" #include <string> #include "string.h" #include <iostream> #include <stdl

背景:尝试编写一个简单的程序,使用字符串在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;
}
#包括“stdafx.h”
#包括
#包括“string.h”
#包括
#包括
使用名称空间std;
int _tmain(int argc,_TCHAR*argv[]
{
字符串值=“1000”;
int size=value.size();
开关(尺寸){
案例1:
打破
案例2:
打破
案例3:
打破
案例4:
值。调整大小(大小+1);
value.insert(value.begin+1',');
打破
违约:
忍受
1>          [
1> _Elem=char,
1> _Traits=std::char_Traits,
1> _Alloc=std::分配器
1>          ]

1> i:\programming\comma\u placeing\u in_numbers\comma\u placeing\u in_numbers\comma\u placeing\u in_numbers.cpp(29):错误C2664:'std::basic_string&std::basic_string::insert(unsigned int,const std::basic_string&'):无法将参数2从'char'转换为'const std::basic_string&' 1> 与 1> [ 1> _Elem=char, 1> _Traits=std::char_Traits, 1> _Alloc=std::分配器 1> ] 1> 原因:无法从“char”转换为“const std::basic_string” 1> 与 1> [ 1> _Elem=char, 1> _Traits=std::char_Traits, 1> _Alloc=std::分配器 1> ] 1> 没有构造函数可以采用源类型,或者构造函数重载解析不明确
编译器对它解释得很好

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

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

这也是编译器的响应。编译器错误:begin是一个函数。请尝试value.begin()谢谢你工作得很好!但是这个错误有外行翻译吗?到目前为止,我理解它是指函数调用缺少()。或者是一个帮助处理编译器错误消息的站点?是的,
begin
是一个函数,函数调用必须有
()
。错误消息表明您在代码中使用了函数名,但忘记了放置参数列表,即
(/*可能在此处*/)谢谢,我现在看到了,问题是函数名是否总是出现在“:”之后:?@user3474943没有
,所以我不知道你在说什么。I:\programming\comma\u placeing\u in_numbers\comma\u placeing\u in_numbers\comma\u placeing\u in_numbers.cpp(29):错误C3867:'std::basic_string::begin':函数调用缺少参数列表;使用'&std::basic_string::begin'创建指向成员的指针
'std::basic_string::begin'
编译器正试图为您提供有关哪个
begin()的详细信息<代码> >您试图调用。这里在代码> STD< /Calp>命名空间中,有一个类< C++ > Basic字符串> <代码>,里面有函数<代码>开始>代码>它的调用缺少参数列表。
value.insert(value.begin+1,',');