【发布时间】:2013-10-13 15:46:41
【问题描述】:
失败是在类 manejo.cpp 的构造函数中,错误是“manejo.cpp:3:16: error: array used as initializer”,我不知道这个错误在哪里。
下面附上manejo.hpp类的源码和manejo.cpp的实现,谢谢
#include "manejo.hpp"
manejo::manejo(){}
manejo::~manejo(){}
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
【问题讨论】:
-
char cadena[128]="";你不能这样做。你真的尝试用谷歌搜索你得到的错误吗? -
你的编译器支持 C++11 吗?如果不是,您不能在声明时初始化非静态数据成员(就像您对
cadena所做的那样)。顺便说一句,检查你的包含警卫,不要使用双下划线。这些是为实现保留的。
标签: c++