错误数组用作初始值设定项,我不知道错误
Error array used as initializer and i don't know the error
失败是在类manejo的构造函数中.cpp,错误是"manejo.cpp:3:16:错误:数组用作初始值设定项",我不知道这个错误在哪里。
向下附上了manejo.hpp类的源代码和manejo.cpp的实现,谢谢
#include "manejo.hpp"
manejo::manejo(){}
manejo::~manejo(){}
马力普
#ifndef __MANEJO_HPP
#define _MANEJO_HPP
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
using std::vector;
using std::string;
class manejo{
private:
char cadena[128]="";
vector <string> linea;
long cantidadPD = 0;
vector <string> palabras;
int Creglas = 0;
vector <string> reglas;
long atoi(const char *str);
public:
manejo();
~manejo();
void EstablecerVariables();
int StoInt (string numero);
};
#endif
char cadena[128]="";
在传统C++中是不合法的(它在 C++11 中是合法的,但显然你没有使用它,否则你不会得到这个错误)。删除=""
,初始化构造函数中的数据成员,而不是类中的数据成员。例如
manejo::manejo()
{
cadena[0] = ' ';
...
}
相关文章:
- 我不知道导致错误的原因 (C3074)
- 我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它
- 函数抛出seg错误,我不知道为什么
- 尝试通过多个函数移动数组,但遇到了我不知道如何修复的错误
- 由于某种原因,我的代码中出现了 [json.exception.type_error.302]。我知道错误意味着什么,但我不知道哪里有故障
- "错误:在'.标记'之前出现预期的主表达式,我不知道为什么
- 我正在制作c ++代码,但发生错误我不知道为什么
- std::cout << glGetString(GL_RENDER) << std::endl;抛出错误但不GL_Renderer或GL_Verision,我不知道为什么?
- 语法检查器指出一些我不知道为什么的错误
- 编写蒙特卡洛集成程序,我不知道为什么我会收到某些错误
- C++代码出现分段错误,我不知道为什么
- 我不知道如何使用 boost,虽然我的老师确实提供了代码,但我遇到了一个错误
- 我同时使用了莱布尼茨和瓦利斯公式来估算π但输出数字错误,我不知道我哪里出错了
- 我的一堆函数出现"undefined reference"错误,我不知道为什么
- 错误 C2064 — 我不知道我做错了什么
- Mingw32-w64 GCC 4.9.2 正则表达式错误,或者我不知道C++
- 错误数组用作初始值设定项,我不知道错误
- 尝试对结构向量进行排序时,我在算法文件中收到 20 个错误。我不知道怎么了?
- 删除数组时出现问题(我不知道这个错误)
- 我的返回语句有一个错误,我不知道要修复