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 :

VC++ 2005 (Erreur LNK2019)


Sujet :

C++

  1. #1
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut VC++ 2005 (Erreur LNK2019)
    Bonjour,je suis content d'étre parmis vous .
    voici mon probleme:

    j'ai des erreurs lors de la generation de mon programme :

    error LNK2019: symbole externe non résolu "bool __cdecl FromString<class GroupeDateHeure>(char const *,class GroupeDateHeure &)" (??$FromString@VGroupeDateHeure@@@@YA_NPBDAAVGroupeDateHeure@@@Z) référencé dans la fonction "void __cdecl FromOctets(class GroupeDateHeure &,class Octets const &)" (?FromOctets@@YAXAAVGroupeDateHeure@@ABVOctets@@@Z) OField.obj


    error LNK2019: symbole externe non résolu "class Archive & __cdecl operator<<(class Archive &,class Tableau<class String> const &)" (??6@YAAAVArchive@@AAV0@ABV?$Tableau@VString@@@@@Z) référencé dans la fonction "class Archive & __cdecl operator<<(class Archive &,class EvenementJournal const &)" (??6@YAAAVArchive@@AAV0@ABVEvenementJournal@@@Z) EvenementJournal.obj

    error LNK2019: symbole externe non résolu "class Archive & __cdecl operator>>(class Archive &,class Tableau<class String> &)" (??5@YAAAVArchive@@AAV0@AAV?$Tableau@VString@@@@@Z) référencé dans la fonction "class Archive & __cdecl operator>>(class Archive &,class EvenementJournal &)" (??5@YAAAVArchive@@AAV0@AAVEvenementJournal@@@Z) EvenementJournal.obj

    merci d'avance pour votre aide , car je suis en court d'idée .

  2. #2
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Est-ce que la réponse est celle-ci (déclaration d'un template dans un .h et définition dans un .cpp) ?

  3. #3
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    salut ,


    je ne sais pas d'ou vien l'erreur ni dans quels codes sources :s. Si je comprend l'erreur cest dans les fichiers EvenementJournal et OField que il y a un probleme non ,

    vous pensez que ces en rapport avec les templates ?

  4. #4
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Citation Envoyé par lui88 Voir le message
    salut ,
    je ne sais pas d'ou vien l'erreur ni dans quels codes sources :s. Si je comprend l'erreur cest dans les fichiers EvenementJournal et OField que il y a un probleme non ,
    Je dirais
    1/dans OField.cpp, tu utilises bool FromString<classGroupeDateHeure>(char const *,class GroupeDateHeure &) qui est déclaré mais non défini : où est déclarée et définie cette fonction ?
    2/dans EvenementJournal.cpp, tu utilises class Archive & __cdecl operator<<(class Archive &,class Tableau<class String> const &) (et l'opérateur symétrique >>) qui est déclaré mais non défini : où est déclarée et définie cette fonction ?

    Citation Envoyé par lui88 Voir le message
    vous pensez que ces en rapport avec les templates ?
    A priori, vu la signature, c'est dans les templates. Souvent, la première fois, on déclare les template dans le .h et on met le source dans le .cpp. D'où le problème de link...

  5. #5
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    ouai je penser aussi a ses fichiers , je vous donne les codes correspondant:

    1) OField.cpp:

    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
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    #include "stdafx.h"
     
    #include "OField.h"
    #include "UtilitairesString.h"
     
    #include "Instrumentation.h"
     
     
    OField* OField::Cloner() const
    {
      INSTRUMENTER(this, "OField* OField::Cloner() const");
     
      return new OField(*this);
    }
     
    bool OField::EstVide() const
    {
      INSTRUMENTER(this, "bool OField::EstVide() const");
     
      return true;
    }
     
    void OField::Vider()
    {
      INSTRUMENTER(this, "void OField::Vider()");
    }
     
    String OField::ToString() const
    {
      INSTRUMENTER(this, "String OField::ToString() const");
     
      return "";
    }
     
    void OField::FromString( pcTChar )
    {
      INSTRUMENTER(this, "void OField::FromString( pcTChar )");
    }
     
    Octets OField::ToOctets() const
    {
      INSTRUMENTER(this, "Octets OField::ToOctets() const");
     
      return Octets();
    }
     
    void OField::FromOctets( const Octets& /*y*/ )
    {
      INSTRUMENTER(this, "void OField::FromOctets( const Octets& y )");
    }
     
    bool OField::operator==( const OField& fld ) const
    { 
      INSTRUMENTER(this, "bool OField::operator==(const OField&  fld)const ");
     
      return true;
    }
     
    bool OField::operator!=( const OField& fld ) const
    { 
      INSTRUMENTER(this, "bool OField::operator!=(const OField&  fld)const ");
     
      return !operator==(fld);
    }
     
    bool OField::operator<( const OField& fld ) const
    { 
      INSTRUMENTER(this, "bool OField::operator<(const OField&  fld)const ");
     
      return false;
    }
     
    bool OField::operator<=( const OField& fld ) const
    { 
     INSTRUMENTER(this, "bool OField::operator<=(const OField&  fld)const ");
     
      return !operator>(fld);
    }
     
    bool OField::operator> ( const OField& fld ) const
    { 
     INSTRUMENTER(this, "bool OField::operator>(const OField&  fld)const ");
     
      return fld<*this;
    }
     
    bool OField::operator>=( const OField& fld ) const
    {
     INSTRUMENTER(this, "bool OField::operator>=(const OField&  fld)const ");
     
      return !operator<(fld);
    }
     
    //==============================================================================
    //                                FromOctets
    //==============================================================================
    _Base_Function void FromOctets( int& i, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(int &  i, const Octets&  y)");
     
      int size = y.Taille();
     
      Assert( size > 0 && size <= sizeof(int), "FromOctets(int&,const Octets&)" );
     
      if      ( size == sizeof(int) )   i = *(const int*)  (pcVoid)y;
      else if ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
      else if ( size == sizeof(char) )  i = *(const char*) (pcVoid)y;
      else Assert( 0, "FromOctets(int&,const Octets&)");
    }
     
    _Base_Function void FromOctets( long& i, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(long &  i, const Octets&  y)");
     
      int size = y.Taille();
     
      Assert( size > 0 && size <= sizeof(long), "FromOctets(long&,const Octets&)" );
     
      if      ( size == sizeof(long) )  i = *(const long*) (pcVoid)y;
      else if ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
      else if ( size == sizeof(char) )  i = *(const char*) (pcVoid)y;
      else Assert( 0, "FromOctets(long&,const Octets&)" );
    }
     
    _Base_Function void FromOctets( short& i, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(short &  i, const Octets&  y)");
     
      int size = y.Taille();
     
      Assert( size > 0 && size <= sizeof(short), "FromOctets(short&,const Octets&)" );
     
      if      ( size == sizeof(short) ) i = *(const short*)(pcVoid)y;
      else if ( size == sizeof(char) )  i = *(const char*) (pcVoid)y;
      else Assert( 0, "FromOctets(short&,const Octets&)" );
    }
     
    _Base_Function void FromOctets( double& i, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(double &  i, const Octets&  y)");
     
      int size = y.Taille();
     
      Assert( size > 0 && size <= sizeof(double), "FromOctets(double&,const Octets&)" );
     
      if      ( size == sizeof(double) ) i = *(const double*)(pcVoid)y;
      else if ( size == sizeof(float) )  i = *(const float*) (pcVoid)y;
      else Assert( 0, "FromOctets(double&,const Octets&)" );
    }
     
    _Base_Function void FromOctets( bool& b, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(bool&  b, const Octets&  y)");
     
      Assert( y.Taille() > 0, "FromOctets(bool&,const Octets&)" );
      b = !_strcmpi((const char*)(pcVoid)y, "O");
    }
     
    _Base_Function void FromOctets( String& str , const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(String&  str, const Octets&  y)");
     
      str = (pcTChar)(pcVoid)y;
    }
     
    _Base_Function void FromOctets( GroupeDateHeure& gdh, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(GroupeDateHeure&  gdh, const Octets&  y)");
     
      FromString( (pcTChar)(pcVoid)y, gdh );
    }
     
    _Base_Function void FromOctets( Octets& y1, const Octets& y )
    {
     INSTRUMENTER(NULL, "void  FromOctets(Octets&  y1, const Octets&  y)");
     
      y1 = y;
    }
     
    //==============================================================================
    //                                ToOctets
    //==============================================================================
    _Base_Function Octets ToOctets( int i )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(int  i)");
     
      return Octets( (pcVoid)&i, sizeof(int) );
    }
     
    _Base_Function Octets ToOctets( long i )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(long  i)");
     
      return Octets( (pcVoid)&i, sizeof(long) );
    }
     
    _Base_Function Octets ToOctets( short i )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(short  i)");
     
      return Octets( (pcVoid)&i, sizeof(short) );
    }
     
    _Base_Function Octets ToOctets( double f )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(double  f)");
     
      return Octets( (pcVoid)&f, sizeof(double) );
    }
     
    _Base_Function Octets ToOctets( bool b )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(bool b)");
     
      String s = b ? "O" : "N";
      return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
    }
     
    _Base_Function Octets ToOctets( const String& s  )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(const String&  s)");
     
      return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
    }
     
    _Base_Function Octets ToOctets( const GroupeDateHeure& gdh )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(const GroupeDateHeure&  gdh)");
     
      String s = ToString( gdh );
      return Octets( (pcVoid)(pcTChar)s, (s.length()+1)*sizeof(TChar) );
    }
     
    _Base_Function Octets ToOctets( const Octets& y )
    {
      INSTRUMENTER(NULL, "Octets ToOctets(const Octets&  y)");
     
      return y;
    }
    1)OField.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
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    #ifndef _O_FIELD_H_
    #define _O_FIELD_H_
     
    #include "BaseDef.h"
     
    #include <local/Base/Types.h>
    #include <local/Base/ValeurDefaut.h>
    #include <local/Base/Octets.h>
    #include <local/Base/CString.h>
     
    ////////////////////////////////////////////
    // OField///////////////////////////////////
     
    class _Base_Class OField
    {
    public:
      virtual ~OField() {}
      virtual OField* Cloner() const;
     
      virtual bool EstVide() const;
      virtual void Vider();
     
      virtual bool operator==( const OField& fld ) const;
      virtual bool operator!=( const OField& fld ) const;
      virtual bool operator< ( const OField& fld ) const;
      virtual bool operator<=( const OField& fld ) const;
      virtual bool operator> ( const OField& fld ) const;
      virtual bool operator>=( const OField& fld ) const;
     
      // Conversions avec les chaines de caractères.
      virtual String ToString() const;
      virtual void FromString( pcTChar );
     
      // Interaction avec la base de données.
      virtual Octets ToOctets() const;
      virtual void FromOctets( const Octets& y );
    };
     
    ////////////////////////////////////////////
    // template<class T> OFld
     
    template<class T>
    class OFld : public ValeurDefaut<T>, public OField
    {
    public:
      OFld() {}
      OFld ( const T& t ) : ValeurDefaut<T>( t ) {}
      virtual ~OFld();
     
      // Fonctions virtuelles.
      virtual OField* Cloner() const;
     
      virtual bool EstVide() const;
      virtual void Vider();
     
      virtual bool operator==( const OField& fld ) const;
      virtual bool operator!=( const OField& fld ) const;
      virtual bool operator< ( const OField& fld ) const;
      virtual bool operator<=( const OField& fld ) const;
      virtual bool operator> ( const OField& fld ) const;
      virtual bool operator>=( const OField& fld ) const;
     
      // Conversions avec les chaines de caractères.
      virtual String ToString() const;
      virtual void FromString( pcTChar s );
     
      // Interaction avec la base de données.
      virtual Octets ToOctets() const;
      virtual void FromOctets( const Octets& y );
     
      inline ValeurDefaut<T>& operator=( const ValeurDefaut<T>& v );
      inline ValeurDefaut<T>& operator=( const T& v );
    };
     
    #define dynamic_castOFld( T, of ) dynamic_cast<const OFld<T >&>( (const OField&)of )
     
    /* ---------------------------- Fonctions inline ---------------------------- */
     
    /* -------------------------------------------------------------------------- *\
       METHODE : OFld<T>::operator=(const ValeurDefaut<T>&)
    \* -------------------------------------------------------------------------- */
    template<class T>
    inline ValeurDefaut<T>& OFld<T>::operator=( const ValeurDefaut<T>& v )
    {
      (ValeurDefaut<T>&)*this = v;
      return *this;
    }
     
    /* -------------------------------------------------------------------------- *\
       METHODE : OFld<T>::operator=(const T&)
    \* -------------------------------------------------------------------------- */
    template<class T>
    inline ValeurDefaut<T>& OFld<T>::operator=( const T& v )
    {
      return ValeurDefaut<T>::operator=( v );
    }
     
    #include "OField.c"
     
    #endif // _O_FIELD_H_
    2)EvenementJournal.cpp

    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
    #include "stdafx.h"
     
    #include "EvenementJournal.h"
     
     
    #include "Archive.h"
     
    #include "Instrumentation.h"
     
    _Base_Function Archive& operator<<( Archive& a, const EvenementJournal& evenement )
    {
       INSTRUMENTER(NULL, "Archive&  operator<<(Archive&  a, const EvenementJournal&  evenement)");
     
      a << (int)evenement.m_eType;
      a << evenement.m_iCategorie;
      a << evenement.m_iIdentificateur;
      a << evenement.m_tstrParametres;
      a << evenement.m_yDonnees;
      a << evenement.m_gdh;
     
      return a;
    }
     
    _Base_Function Archive& operator>>( Archive& a, EvenementJournal& evenement )
    {
     INSTRUMENTER(NULL, "Archive&  operator>>(Archive&  a, EvenementJournal&  evenement)");
     
      int i;
      a >> i;
      evenement.m_eType = (EvenementJournal::TypeEv)i;
      a >> evenement.m_iCategorie;
      a >> evenement.m_iIdentificateur;
      a >> evenement.m_tstrParametres;
      a >> evenement.m_yDonnees;
      a >> evenement.m_gdh;
     
      return a;
    }
    2)EvenementJournal.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
    #ifndef _EVENEMENT_JOURNAL_H_
    #define _EVENEMENT_JOURNAL_H_
     
    #include "BaseDef.h"
     
    #include "CString.h"
    #include "GroupeDateHeure.h"
    #include "Tableau.h"
    #include "Octets.h"
     
    class Archive;
     
     
    /* -------------------------------------------------------------------------- *\
      CLASSE : EvenementJournal
      ROLE :
    \* -------------------------------------------------------------------------- */
    class _Base_Class EvenementJournal
    {
    public:
      enum TypeEv { Indefini = 0, Erreur, Warning, Information, SuccesAudit, EchecAudit };
     
      inline EvenementJournal();
     
      inline EvenementJournal(
               TypeEv eType,
               int    iCategorie,
               int    iIdentificateur );
     
      inline EvenementJournal(
               TypeEv                 eType,
               int                    iCategorie,
               int                    iIdentificateur,
               const Tableau<String>& tstrParametres );
     
      inline EvenementJournal(
               TypeEv                 eType,
               int                    iCategorie,
               int                    iIdentificateur,
               const Tableau<String>& tstrParametres,
               const Octets&          yDonnees );
     
      inline EvenementJournal::TypeEv Type() const;
      inline void Type( TypeEv eType );
     
      inline int Categorie() const;
      inline void Categorie( int iCategorie );
     
      inline int Identificateur() const;
      inline void Identificateur( int iIdentificateur );
     
      inline Tableau<String> Parametres() const;
      inline void Parametres( const Tableau<String>& tstrParametres );
     
      inline Octets Donnees() const;
      inline void Donnees( const Octets& yDonnees );
     
      inline GroupeDateHeure Date() const;
      inline void Date( const GroupeDateHeure& gdh );
     
      inline bool operator==( const EvenementJournal& evenement ) const;
      inline bool operator!=( const EvenementJournal& evenement ) const;
     
      friend _Base_Function Archive& operator<<( Archive& a,  const EvenementJournal& evenement );
      friend _Base_Function Archive& operator>>( Archive& a,  EvenementJournal& evenement );
     
    private:
      EvenementJournal::TypeEv m_eType;
      int                      m_iCategorie;
      int                      m_iIdentificateur;
      Tableau<String>          m_tstrParametres;
      Octets                   m_yDonnees;
      GroupeDateHeure          m_gdh;
    };
     
    #include "EvenementJournal.inl"
     
    #endif // _EVENEMENT_JOURNAL_H_

  6. #6
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Je ne trouve pas de déclaration de FromString<classGroupeDateHeure>(char const *,class GroupeDateHeure &) . Peut-être dans "UtilitairesString.h" ?
    Idem pour Archive & __cdecl operator<<(class Archive &,class Tableau<class String> const &) : dans "Archive.h" ?

  7. #7
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    effectivement dans utiliairestring , mais dans archive.h je pense pas je vous les mis quand meme on cest jamais .

    UtilitaireString.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
    #ifndef _UTILITAIRES_STRING_H_
    #define _UTILITAIRES_STRING_H_
     
    #include "BaseDef.h"
     
    /* --------------------- Les fichiers include système ----------------------- */
    #include <strstream>
    using namespace std;
     
     
    #include "CString.h"
    #include "Tableau.h"
     
    /* ------------------------------------------------------------------------- *\
      FONCTION : ToString(T)
      ROLE :
       Convertir un type T en sa représentation textuelle
      REMARQUE : 
       L'implémention proposée suppose qu'il existe un opérateur d'insertion dans
       un ostream.
      EXEMPLE :
       <<
       String s = ToString(M_PI);
       >>
     
       <s> contient "3.14159265358979323846"
    \* ------------------------------------------------------------------------- */
    template <class T> String ToString(T t);
    template <class T> String ToString(T t,int precision);
    template <class T> void ToString(T t, String& str,int precision);
     
    /* ------------------------------------------------------------------------- *\
      FONCTION : FromString(const char *, T&)
      ROLE :
       Convertir une représentation textuelle d'une valeur d'type T en sa valeur
      REMARQUE : 
       L'implémention proposée suppose qu'il existe un opérateur d'extraction depuis
       un istream.
      EXEMPLE :
       <<
       const char *s="3.14159265358979323846";
       double pi;
       FromString(s, pi);
       >>
     
       <pi> contient 3.14159265358979323846
    \* ------------------------------------------------------------------------- */
    template <class T> bool FromString(const char *s, T &t);
     
     
    _Base_Function Tableau<String> CreerTableauString(const char *chaine, const char *delimiteurs=",");
    _Base_Function Tableau<String> SousTableau(const Tableau<String> &tableau, const Tableau<int> &indicesSousTableau);
    _Base_Function Tableau<int> IndicesSousTableau(const Tableau<String> &tableau, const Tableau<String> &sousTableau);
     
    #ifndef unix
    #include "UtilitairesString.c"
    #endif
     
    #endif // _UTILITAIRES_STRING_H_

    Archive.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
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    class _Base_Class ObjetConnu
    {
     friend class Archive;
     
     private:
     // Construteur
     ObjetConnu(int no, const void *p);
     
     // Données membres
     int noObjet;
     const void *ptr;
     
     public:
      // Constructeur public (pour les Blocs)
      ObjetConnu()  {noObjet=0; ptr=0; }
     
      // Destructeur
      ~ObjetConnu() {}
     
     // opérations
     int operator<(const ObjetConnu &autre) const { return (autre.ptr < ptr); }
     int operator==(const ObjetConnu &autre) const { return (autre.ptr == ptr); }
    };
     
     
     
    /* -------------------------------------------------------------------------- *\
      CLASSE : Archive
      ROLE :
       La classe Archive permet de mettre en oeuvre la persistance d'objets avec
       leurs relations (pointeurs) simplement en les y insérant et en les y extrayant
       comme on le fait avec des flux. La classe <Archive>, bien que non abstraite, n'est
       pas destinée à être instanciée directement mais elle est la classe de base des 
       classes comme <FichierArchive>.
     
       On pourrait également dériver une classe <MemoireArchive> basée sur les
       <strstream> et qui serait utilisée pour les Presse-Papiers.
      VOIR AUSSI :
        CLASSE FichierArchive
    \* -------------------------------------------------------------------------- */
    class _Base_Class Archive
    {
     public :
       enum Type {BINAIRE, ASCII};
     
       // Constructeurs et Destructeur
       Archive();
       Archive(std::istream *pFlux, Type type=BINAIRE);
       Archive(std::ostream *pFlux, Type type=BINAIRE);
       virtual ~Archive();
     
       // Informations
       ios::open_mode DemanderModeOuverture()     { return mode; }      // ios::in ou ios::out
       operator void *() const { return flux->operator void *(); }
       int operator !() const { return flux->operator !(); }
       int Lecture() const {return mode==ios::in; }
       int Ecriture() const {return mode==ios::out; }
       int Eof() const { return flux->eof(); }
     
       // Enregistrement d'un objet
       const void *ObjetDeNumero(int no);
       int NumeroDeObjet(const void *objet);
       int EnregistrerObjet(const void *); 
     
       // Insertion
       Archive& operator<<(const char *);
       Archive& operator<<(char);
       Archive& operator<<(short);
       Archive& operator<<(int);
       Archive& operator<<(long);
       Archive& operator<<(float);
       Archive& operator<<(double);
       Archive& operator<<(unsigned char);
       Archive& operator<<(unsigned short);
       Archive& operator<<(unsigned int);
       Archive& operator<<(unsigned long);
       Archive& operator<<(bool);
       Archive& operator<<(streambuf *);
       Archive& operator<<(std::ostream& (*)(std::ostream&));
       Archive& operator<<(ios& (*)(ios&));
       Archive& operator<<(const String &);
       Archive& operator<<(const MetaClasse *);
       Archive& write(const char *,int);
     
       // Extraction
       Archive& operator>>(char*);
       Archive& operator>>(char&);
       Archive& operator>>(short&);
       Archive& operator>>(int&);
       Archive& operator>>(long&);
       Archive& operator>>(float&);
       Archive& operator>>(double&);
       Archive& operator>>(unsigned char&);
       Archive& operator>>(unsigned short&);
       Archive& operator>>(unsigned int&);
       Archive& operator>>(unsigned long&);
       Archive& operator>>(bool&);
       Archive& operator>>(streambuf*);
       Archive& operator>>(ios& (*)(ios&));
       Archive& operator>>(String &);
       Archive& operator>>(const MetaClasse *&);
       Archive& read(char *,int);
     
       // Commentaires
       Archive& Commentaire(const char*);
     
     protected:
      // Données membres
      ios::open_mode mode;                   // Mode d'ouverture de l'archive (ios::in ou ios::out)
      Type type;                             // Archive binaire ou ascii
      iostream *flux;
     
      // Fonctions membres
      int Ouvrir();
      void Fermer();
     
     private:
      Bloc<ObjetConnu> lesObjets;           // Objets dans le dictionnaire
      int nbObjets;                          // nombre d'éléments dans le dictionnaire
    };
     
     
     
    /* -------------------------------------------------------------------------- *\
      FONCTION : operator<<(Archive &, const T *)
      ROLE :
       Permettre d'insérer un pointeur sur un objet dans une archive
      ENTREES :
       <ar> est l'archive dans laquelle on veut écrire 
       <pObjet> est le pointeur sur l'objet à écrire
    \* -------------------------------------------------------------------------- */
    template <class T> Archive& operator<<(Archive &ar, const T *pObjet);
     
    /* -------------------------------------------------------------------------- *\
      FONCTION : operator>>(Archive &, const T *&)
      ROLE :
       Permettre d'extraire un pointeur sur un objet d'une archive
      ENTREE :
       <ar> est l'archive dans laquelle on veut extraire
      SORTIE :
       <pObjet> sera rempli avec l'adresse de l'objet extrait
    \* -------------------------------------------------------------------------- */
    template <class T> Archive& operator>>(Archive &ar, const T* &pObjet);
     
     
    #ifndef unix
    #include "Archive.c"
    #endif // unix
     
    #endif // _ARCHIVE_H_

  8. #8
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    unix est défini comme directive de compilation ?

  9. #9
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    je ne pense pas .

    Comment je peut regardé si c'est une directive de compilation unix qui est definie ou pas ?

  10. #10
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Quel est ton environnement de développement (Visual ? Code::Block ? ... ?)

  11. #11
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    visual studio c++ 2005

  12. #12
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Project/ Properties -> Configuration Properties - C/C++ - Preprocessor -> Preprocessor Definitions
    Si ce n'est pas le cas, il faut probablement changer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    #ifndef unix
    #include "UtilitairesString.c"
    #endif
    en
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    // #ifndef unix
    #include "UtilitairesString.c"
    // #endif
    Idem pour Archive.h
    Images attachées Images attachées  

  13. #13
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    Je viens de faire tout se que vous m'avez dit , mais il y a toujours les mêmes erreurs.

  14. #14
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Où est la définition (le corps, l'implémentation) de template <class T> bool FromString(const char *s, T &t); ?

  15. #15
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    le corp de cette template est dans OField.cpp normalement

  16. #16
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    En tout cas, pas dans la version que tu as postée. Il y a :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    void OField::FromString( pcTChar )
    {
      INSTRUMENTER(this, "void OField::FromString( pcTChar )");
    }
    Mais, il n'y a pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    template <class T> bool FromString(const char *s, T &t)
    {
    // implémentation.
    }
    L'erreur n'est-elle pas là ? Cette méthode n'est jamais définie. Il en serait de même pour les opérateurs << et >> sur les archives&Tableau<class String> ?

  17. #17
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    //template <class T> bool FromString(const char *s, T &t)
    et

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    //FromString( (pcTChar)(pcVoid)y, gdh );
    (OField.cpp)


    quand je fait celà , il m'enleve cette erreur :

    error LNK2019: symbole externe non résolu "bool __cdecl FromString<class GroupeDateHeure>(char const *,class GroupeDateHeure &)" (??$FromString@VGroupeDateHeure@@@@YA_NPBDAAVGroupeDateHeure@@@Z) référencé dans la fonction "void __cdecl FromOctets(class GroupeDateHeure &,class Octets const &)" (?FromOctets@@YAXAAVGroupeDateHeure@@ABVOctets@@@Z) OField.obj

  18. #18
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    C'est donc bien que la fonction n'est définie nulle part. Je pense qu'il en est de même pour les 2 autres. Ton prédécesseur avait dû les déclarer mais pas les définir. T'es venu, tu les as utilisé et bing !

  19. #19
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    68
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 68
    Par défaut
    je croit que vous avez raison ^^ ,

    pour les deux autre erreurs comment pourais-je les corrigées?

  20. #20
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par défaut
    Soit tu écris les fonctions qui manquent soit tu supprimes leur appel. Cela dépend de l'objectif du code.
    Je pense qu'il s'agit des deux lignes en gras et rouge ci-dessous :
    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
    _Base_Function Archive& operator<<( Archive& a, const EvenementJournal& evenement )
    {
       INSTRUMENTER(NULL, "Archive&  operator<<(Archive&  a, const EvenementJournal&  evenement)");
     
      a << (int)evenement.m_eType;
      a << evenement.m_iCategorie;
      a << evenement.m_iIdentificateur;
      a << evenement.m_tstrParametres;
      a << evenement.m_yDonnees;
      a << evenement.m_gdh;
     
      return a;
    }
     
    _Base_Function Archive& operator>>( Archive& a, EvenementJournal& evenement )
    {
     INSTRUMENTER(NULL, "Archive&  operator>>(Archive&  a, EvenementJournal&  evenement)");
     
      int i;
      a >> i;
      evenement.m_eType = (EvenementJournal::TypeEv)i;
      a >> evenement.m_iCategorie;
      a >> evenement.m_iIdentificateur;
      a >> evenement.m_tstrParametres;
      a >> evenement.m_yDonnees;
      a >> evenement.m_gdh;
     
      return a;
    }

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Visual Studio 2005 : erreur C2668
    Par Patriarch24 dans le forum MFC
    Réponses: 2
    Dernier message: 26/04/2006, 17h34
  2. Une autre erreur LNK2019 (visual c++ express)
    Par crossbowman dans le forum OpenGL
    Réponses: 2
    Dernier message: 26/02/2006, 03h49
  3. une autre erreur LNK2019
    Par crossbowman dans le forum C++
    Réponses: 5
    Dernier message: 25/02/2006, 22h29
  4. [C++ 2005] Erreur C3699
    Par JulienDuSud dans le forum C++/CLI
    Réponses: 6
    Dernier message: 19/12/2005, 10h23
  5. Delphi 2005 : Erreur de compilation du programme
    Par bigbestboy dans le forum Langage
    Réponses: 6
    Dernier message: 03/08/2005, 18h14

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