Initialisation d'un tableau dans un .h
Bonjour,
désolé de soulever un problème qui a sans doute déjà été traité, mais je n'arrive pas à trouver tout seul : je voudrais initialiser un tableau de string constant dans mon .h et je n'y arrive pas ; j'ai toujours le message :
erreur: a brace-enclosed initializer is not allowed here before «{» token
Voici mon code simplifié à l'extrême :
truc.h :
Code:
1 2 3 4 5 6 7 8
| include <string>
class truc
{
static const std::string tabmois[]={"jan","fev","mar"};
truc();
void affiche();
}; |
truc.cc :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include <iostream>
#include </home/bidule/Prog/TESTXDR/TESTCPP/TEST/truc.h>
using namespace std;
truc::truc()
{
cout << "constructeur" << endl;
}
void truc::affiche()
{
cout << "mois de " << tabmois[0] << endl;
} |
Merci d'avance pour vos réponses