IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C++ Discussion :

boost création multiarray classe


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut boost création multiarray classe
    Bonjour,

    j'ai un problème lorsque j'essaye de générer une multiarray membre d'une classe et de l'utiliser par la suite.

    dans le .h j'ai mis ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    private:  
       typedef boost::multi_array<float, 5> array_type;
       array_type::extent_gen extents;
       array_type data(boost::extents[1][1][1][1][1]);
    je veux juste l'initialiser.

    et dans le .cpp associé à la classe.
    je veux resize la matrice data.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    data.resize([2][2][2][2][2]);
    (les 2 c'est juste pour l'essai. normalement c'est des size_x,size_y, etc ...)

    si je fais ça j'ai les erreur suivantes:

    test_class.h:75: error: expected `;' before '(' token

    test_class.cpp: In member function `void Images::reading(std::string, std::vector<std::string, std::allocator<std::string> >&)':
    test_class.cpp:479: error: `data' undeclared (first use this function)
    test_class.cpp:479: error: (Each undeclared identifier is reported only once for each function it appears in.)

    test_class.cpp:479: error: expected primary-expression before '[' token
    si je commente la ligne dans le point cpp j'ai plus que l'erreur suivante:
    In file included from test_class.cpp:19:
    test_class.h:75: error: expected `;' before '(' token
    quelqu'un vois le problème ?

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 147
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 147
    Billets dans le blog
    4
    Par défaut
    Bonjour,

    quelle est la ligne 75 du .h ? L'erreur vient clairement de là.

    Ensuite, sur la doc de boost, l'exemple n'est pas identique au tien:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    typedef boost::multi_array<double, 3> array_type;
      typedef array_type::index index;
      array_type A(boost::extents[3][4][2]);
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut
    arf oui désolé.

    la ligne 75 de mon .h ça correspond à la ligne 4 dans l'extrait que j'ai mis.
    la ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     array_type data(boost::extents[1][1][1][1][1]);
    et j'ai pris cet exemple dans la doc de boost:
    typedef boost::multi_array<double, 3> array_type;

    array_type::extent_gen extents;
    array_type A(extents[2][3][4]);
    j'avais essayé aussi l'exemple que tu cites. mais sans succès non plus.

  4. #4
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2013
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Février 2013
    Messages : 23
    Par défaut
    Citation Envoyé par svagrim Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    private:  
       typedef boost::multi_array<float, 5> array_type;
       array_type::extent_gen extents;
       array_type data(boost::extents[1][1][1][1][1]);
    Salut,

    A mon humble avis, tu ferais bien de retirer le namespace boost:: de boost::extents.
    Tu définis une variable extents la ligne juste au dessus (array_type::extent_gen extents;).
    Par contre, tu ne l'utilises pas. Mais tu vas chercher un symbol extents dans le namespace boost, qui ne correspond pas à ce que tu veux.

    Peut-être que ce n'est pas ton erreur. En tout cas, c'est louche

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut
    nan ça ne change rien.
    par contre oui je suis d'accord avec ton argument.
    je sais pas pourquoi dans la doc de boost il remette boost::...

    mais bon c'est pas ça l'erreur. toujours le meme probleme de compilation sans ça.

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut
    arf je m'en sors toujours pas ...
    j'ai beau parcourir l'aide de boost je vois pas.
    personne n'a d'idée du problème ?

  7. #7
    Expert éminent

    Femme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    5 202
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 5 202
    Par défaut
    Montre-nous les 80 premières lignes de ton .h, que l'on voit ce qui peut se passer.

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut
    voici la totalité du .h :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    #ifndef TEST_CLASS_H
    #define TEST_CLASS_H
     
    #include <vector>
    #include <string>
    #include <boost/multi_array.hpp>
     
    #define WANT_TRACE 1
     
    /*reading the vff files, header and images, and sort them in the variable ... */
     
    class Images
    {   
    public:
     
       Images();
       void reading(std::string input, std::vector<std::string> &files);
     
    private:   
       std::vector<std::string> ttype; 
       std::vector<std::vector<int> > tsize; 
       std::vector<int> tbits;
       std::vector<std::string> trank;
       std::vector<std::string> tbands;
       std::vector<int> ty_bin;
       std::vector<int> tz_bin;
       std::vector<float> trfan_y;
       std::vector<float> trfan_z;
       std::vector<float> tmin;
       std::vector<float> tmax;
       std::vector<float> twater;
       std::vector<float> tair;
       std::vector<float> tbonehu;
       std::vector<float> tangle_increment;
       std::vector<float> tcenter_of_rotation;
       std::vector<float> tcentral_slice;
       std::vector<std::vector<float> > tspacing;
       std::vector<std::vector<float> > torigin;
       std::vector<std::string> tformat;
       std::vector<float> telementsize;
       std::vector<std::string> tmodality;
       std::vector<std::string> tdate;
       std::vector<std::string> ttitle;
       std::vector<std::string> tsubject;
       std::vector<std::string> treverse_order;
       std::vector<std::string> trecon_sysid;
       std::vector<std::string> tmacaddr;
       std::vector<int> trawsize;
       std::vector<float> tcurrent;
       std::vector<std::string> tcurrentUnit;
       std::vector<std::string> tdataSourceJID;
       std::vector<std::string> texam;
       std::vector<float> texposure;
       std::vector<float> tframesAverage;
       std::vector<float> tgain;
       std::vector<float> tgantryPosition;
       std::vector<float> tincrementAngle;
       std::vector<float> toffset;
       std::vector<std::string> tproject;
       std::vector<std::string> tprotocol;
       std::vector<std::string> tscanTechnique;
       std::vector<std::string> tscanType;
       std::vector<std::string> tsequence;
       std::vector<std::string> tserialNumber;
       std::vector<std::string> tseries;
       std::vector<std::string> tseriesVersion;
       std::vector<float> ttablePosition; 
       std::vector<float> tvoltage;
       std::vector<std::string> tvoltageUnit;
       std::vector<std::string> tspacingUnit;       
     
       // Create a 3D array that is 1 x 1 x 1 x 1 x 1 to start
       typedef boost::multi_array<float, 5> array_type;
       array_type::extent_gen extents;
       array_type data(extents[1][1][1][1][1]);
    //   array_type A(boost::extents[3][4][2][4][4]);
     
    };
     
    #endif // TEST_CLASS_H
    y a pas grand chose dedans.

  9. #9
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    245
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Juin 2007
    Messages : 245
    Par défaut
    voici la totalité du .h :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    #ifndef TEST_CLASS_H
    #define TEST_CLASS_H
     
    #include <vector>
    #include <string>
    #include <boost/multi_array.hpp>
     
    #define WANT_TRACE 1
     
    /*reading the vff files, header and images, and sort them in the variable ... */
     
    class Images
    {   
    public:
     
       Images();
       void reading(std::string input, std::vector<std::string> &files);
     
    private:   
       std::vector<std::string> ttype; 
       std::vector<std::vector<int> > tsize; 
       std::vector<int> tbits;
       std::vector<std::string> trank;
       std::vector<std::string> tbands;
       std::vector<int> ty_bin;
       std::vector<int> tz_bin;
       std::vector<float> trfan_y;
       std::vector<float> trfan_z;
       std::vector<float> tmin;
       std::vector<float> tmax;
       std::vector<float> twater;
       std::vector<float> tair;
       std::vector<float> tbonehu;
       std::vector<float> tangle_increment;
       std::vector<float> tcenter_of_rotation;
       std::vector<float> tcentral_slice;
       std::vector<std::vector<float> > tspacing;
       std::vector<std::vector<float> > torigin;
       std::vector<std::string> tformat;
       std::vector<float> telementsize;
       std::vector<std::string> tmodality;
       std::vector<std::string> tdate;
       std::vector<std::string> ttitle;
       std::vector<std::string> tsubject;
       std::vector<std::string> treverse_order;
       std::vector<std::string> trecon_sysid;
       std::vector<std::string> tmacaddr;
       std::vector<int> trawsize;
       std::vector<float> tcurrent;
       std::vector<std::string> tcurrentUnit;
       std::vector<std::string> tdataSourceJID;
       std::vector<std::string> texam;
       std::vector<float> texposure;
       std::vector<float> tframesAverage;
       std::vector<float> tgain;
       std::vector<float> tgantryPosition;
       std::vector<float> tincrementAngle;
       std::vector<float> toffset;
       std::vector<std::string> tproject;
       std::vector<std::string> tprotocol;
       std::vector<std::string> tscanTechnique;
       std::vector<std::string> tscanType;
       std::vector<std::string> tsequence;
       std::vector<std::string> tserialNumber;
       std::vector<std::string> tseries;
       std::vector<std::string> tseriesVersion;
       std::vector<float> ttablePosition; 
       std::vector<float> tvoltage;
       std::vector<std::string> tvoltageUnit;
       std::vector<std::string> tspacingUnit;       
     
       // Create a 3D array that is 1 x 1 x 1 x 1 x 1 to start
       typedef boost::multi_array<float, 5> array_type;
       array_type::extent_gen extents;
       array_type data(extents[1][1][1][1][1]);
    //   array_type A(boost::extents[3][4][2][4][4]);
     
    };
     
    #endif // TEST_CLASS_H
    y a pas grand chose dedans.

Discussions similaires

  1. [RMI] problème Création *_stub.class et *_skel.class
    Par philobedo dans le forum API standards et tierces
    Réponses: 6
    Dernier message: 29/05/2006, 20h03
  2. Contrôler l'ordre de création de classes globales
    Par 10_GOTO_10 dans le forum C++
    Réponses: 4
    Dernier message: 24/04/2006, 20h39
  3. Création de classe exception
    Par HNT dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 03/01/2006, 15h53
  4. Création de classes à la volée...
    Par ouiffi dans le forum Langage
    Réponses: 8
    Dernier message: 16/12/2005, 18h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo