错误数组用作初始化程序,我不知道错误

Car*_*son 0 c++

失败的是在类manejo.cpp的构造函数中,错误是"manejo.cpp:3:16:error:array用作初始化程序",我不知道这个错误在哪里.

to down附加了manejo.hpp类的源代码和manejo.cpp的实现,谢谢

#include "manejo.hpp"

manejo::manejo(){}
manejo::~manejo(){}
Run Code Online (Sandbox Code Playgroud)

HPP

#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 
Run Code Online (Sandbox Code Playgroud)

joh*_*ohn 7

这个

 char cadena[128]="";
Run Code Online (Sandbox Code Playgroud)

在传统的C++中是不合法的(它在C++ 11中是合法的,但显然你没有使用它,否则你不会得到这个错误).删除="",初始化构造函数中的数据成员,而不是在类中.例如

manejo::manejo()
{
    cadena[0] = '\0';
    ...
}
Run Code Online (Sandbox Code Playgroud)