失敗的是在類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] =「」;'你不能這樣做。你真的試圖谷歌你得到的錯誤? – BartoszKP
你的編譯器是否支持C++ 11?如果沒有,你不能在聲明點初始化非靜態數據成員(就像你使用'cadena'一樣)。另外,請檢查您的包含警衛,並且不要使用雙下劃線。這些保留用於實施。 – juanchopanza