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 :

Problèmes de liens entre les .h et .cxx ? Plein d'erreurs de compilation !


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 21
    Par défaut Problèmes de liens entre les .h et .cxx ? Plein d'erreurs de compilation !
    Salut tout le monde !

    Voila j'ai diverses erreurs de compilation lorsque je compile un code en C++ sensé appilquer la méthode des tableaux (programmation linéaire) a une matrix saisie par l'utilisateur (dans un shell).
    Les algorythmes sont peut être mauvais, mais c'est pas tellement ca le problème, ce qui me gènent ce sont les erreurs de syntaxe que je nois pas !

    Pour coder j'utilise VIm sous Ubuntu.
    Je compile avec g++
    Mes fichiers sont :
    ...tables_method2/main.cxx
    ...tables_method2/TM_Util.cxx
    ...tables_method2/include/TM_Util.h
    Je compile avec la commande : g++ *.cxx -I include/
    Et je n'utilise aucune bibliotheque, a part les trucs standards.

    A la compilation je recois énormément d'erreurs ! Mon code n'est pas parfait mais je ne pense pas qu'il soit dégueulasse au point de me sortir des centaines de lignes d'erreurs !
    Je ne m'attends pas a ce que vous corrigiez tout mon code, vous avez surement autre chose a faire, mais si vous pouviez m'eclairer sur ca serait tres sympa ! =)

    Code txt : 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
    virus721@area721m:~/Iut/projects/tables_method2$ g++ *.cxx -I include/
    In file included from main.cxx:9:
    include/TM_Util.h:38: error: ‘VVLDouble_t’ does not name a type
    include/TM_Util.h:43: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    include/TM_Util.h:49: error: ISO C++ forbids declaration of ‘CLUint’ with no type
    include/TM_Util.h:49: error: expected ‘;’ before ‘&’ token
    include/TM_Util.h:50: error: ISO C++ forbids declaration of ‘CLUint’ with no type
    include/TM_Util.h:50: error: expected ‘;’ before ‘&’ token
    include/TM_Util.h:69: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, const nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    include/TM_Util.h:72: error: variable or field ‘TablesMethod’ declared void
    include/TM_Util.h:72: error: ‘CLUint’ was not declared in this scope
    include/TM_Util.h:72: error: ‘width’ was not declared in this scope
    include/TM_Util.h:72: error: ‘CLUint’ was not declared in this scope
    include/TM_Util.h:72: error: ‘height’ was not declared in this scope
    main.cxx: In function ‘int main(int, char**)’:
    main.cxx:15: error: ‘TablesMethod’ was not declared in this scope
    In file included from TM_Util.h:14,
                     from TM_Util.cxx:14:
    include/TM_Util.h:38: error: ‘VVLDouble_t’ does not name a type
    include/TM_Util.h:43: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    include/TM_Util.h:49: error: ISO C++ forbids declaration of ‘CLUint’ with no type
    include/TM_Util.h:49: error: expected ‘;’ before ‘&’ token
    include/TM_Util.h:50: error: ISO C++ forbids declaration of ‘CLUint’ with no type
    include/TM_Util.h:50: error: expected ‘;’ before ‘&’ token
    include/TM_Util.h:69: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, const nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    include/TM_Util.h:72: error: variable or field ‘TablesMethod’ declared void
    include/TM_Util.h:72: error: ‘CLUint’ was not declared in this scope
    include/TM_Util.h:72: error: ‘width’ was not declared in this scope
    include/TM_Util.h:72: error: ‘CLUint’ was not declared in this scope
    include/TM_Util.h:72: error: ‘height’ was not declared in this scope
    In file included from TM_Util.cxx:14:
    TM_Util.h: In constructor ‘nsTablesMethod::TM_Matrix::TM_Matrix(const nsTablesMethod::CLUint_t&, const nsTablesMethod::CLUint_t&)’:
    TM_Util.h:33: error: ‘m_Matrix’ was not declared in this scope
    TM_Util.h: At global scope:
    TM_Util.h:38: error: no ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getPivotCol() const’ member function declared in class ‘nsTablesMethod::TM_Matrix’
    TM_Util.h:45: error: no ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getPivotLin() const’ member function declared in class ‘nsTablesMethod::TM_Matrix’
    TM_Util.h:66: error: expected initializer before ‘&’ token
    TM_Util.h: In member function ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getHeight() const’:
    TM_Util.h:75: error: ‘m_Matrix’ was not declared in this scope
    TM_Util.h:76: warning: returning reference to temporary
    TM_Util.h: At global scope:
    TM_Util.h:83: error: expected initializer before ‘&’ token
    TM_Util.h:90: error: non-member function ‘bool nsTablesMethod::isSolved()’ cannot have cv-qualifier
    TM_Util.h: In function ‘bool nsTablesMethod::isSolved()’:
    TM_Util.h:92: error: ‘getWidth’ was not declared in this scope
    TM_Util.h:93: error: ‘getHeight’ was not declared in this scope
    TM_Util.h:94: error: ‘m_Matrix’ was not declared in this scope
    TM_Util.h: At global scope:
    TM_Util.h:104: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, const nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    TM_Util.h:114: error: variable or field ‘TablesMethod’ declared void
    TM_Util.h:114: error: ‘CLUint’ was not declared in this scope
    TM_Util.h:114: error: ‘CLUint’ was not declared in this scope
    TM_Util.h: In function ‘void nsTablesMethod::InitMat(nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:131: error: expected ‘;’ before ‘for’
    TM_Util.h:131: error: ‘i’ was not declared in this scope
    TM_Util.h:131: error: expected ‘;’ before ‘)’ token
    TM_Util.h:132: error: ‘j’ was not declared in this scope
    TM_Util.h:132: error: expected ‘;’ before ‘)’ token
    TM_Util.h: In function ‘nsTablesMethod::TM_Matrix& nsTablesMethod::GenNextMat(const nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:145: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘GetWidth’
    TM_Util.h:149: error: ‘FillPivotCol’ was not declared in this scope
    TM_Util.h:150: error: ‘FillPivotLin’ was not declared in this scope
    TM_Util.h:145: warning: reference to local variable ‘newMat’ returned
    TM_Util.h: In function ‘void nsTablesMethod::FillPivotColumn(nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:161: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.h:162: error: no match foroperator[]’ in ‘mat[i]’
    TM_Util.h:162: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.h: In function ‘void nsTablesMethod::FillPivotLine(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:170: error: ‘getPivotLin’ was not declared in this scope
    TM_Util.h:170: error: ‘i’ was not declared in this scope
    TM_Util.h:171: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.h: In function ‘void nsTablesMethod::FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:179: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.h:182: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.h:183: error: no match foroperator[]’ in ‘newMat[i]’
    TM_Util.h:183: error: no match foroperator[]’ in ‘oldMat[i]’
    TM_Util.h:183: error: no match foroperator[]’ in ‘newMat[i]’
    TM_Util.h:183: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.h:184: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.h: In function ‘void nsTablesMethod::ShowMat(const nsTablesMethod::TM_Matrix&)’:
    TM_Util.h:196: error: ‘finalMat’ was not declared in this scope
    TM_Util.h:204: error: ‘finalMat’ was not declared in this scope
    TM_Util.h:215: error: ‘finalMat’ was not declared in this scope
    TM_Util.cxx: At global scope:
    TM_Util.cxx:28: error: redefinition of ‘nsTablesMethod::TM_Matrix::TM_Matrix(const nsTablesMethod::CLUint_t&, const nsTablesMethod::CLUint_t&)’
    TM_Util.h:28: error: ‘nsTablesMethod::TM_Matrix::TM_Matrix(const nsTablesMethod::CLUint_t&, const nsTablesMethod::CLUint_t&)’ previously defined here
    TM_Util.cxx:38: error: no ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getPivotCol() const’ member function declared in class ‘nsTablesMethod::TM_Matrix’
    TM_Util.cxx:45: error: no ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getPivotLin() const’ member function declared in class ‘nsTablesMethod::TM_Matrix’
    TM_Util.cxx:52: error: redefinition of ‘void nsTablesMethod::TM_Matrix::setPivotCol(const nsTablesMethod::CLUint_t&)’
    TM_Util.h:52: error: ‘void nsTablesMethod::TM_Matrix::setPivotCol(const nsTablesMethod::CLUint_t&)’ previously defined here
    TM_Util.cxx:59: error: redefinition of ‘void nsTablesMethod::TM_Matrix::setPivotLin(const nsTablesMethod::CLUint_t&)’
    TM_Util.h:59: error: ‘void nsTablesMethod::TM_Matrix::setPivotLin(const nsTablesMethod::CLUint_t&)’ previously defined here
    TM_Util.cxx:66: error: expected initializer before ‘&’ token
    TM_Util.cxx:73: error: redefinition of ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getHeight() const’
    TM_Util.h:73: error: ‘const nsTablesMethod::CLUint_t& nsTablesMethod::TM_Matrix::getHeight() const’ previously defined here
    TM_Util.cxx:83: error: expected initializer before ‘&’ token
    TM_Util.cxx:90: error: non-member function ‘bool nsTablesMethod::isSolved()’ cannot have cv-qualifier
    TM_Util.cxx: In function ‘bool nsTablesMethod::isSolved()’:
    TM_Util.cxx:90: error: redefinition of ‘bool nsTablesMethod::isSolved()’
    TM_Util.h:90: error: ‘bool nsTablesMethod::isSolved()’ previously defined here
    TM_Util.cxx:92: error: ‘getWidth’ was not declared in this scope
    TM_Util.cxx:93: error: ‘getHeight’ was not declared in this scope
    TM_Util.cxx:94: error: ‘m_Matrix’ was not declared in this scope
    TM_Util.cxx: At global scope:
    TM_Util.cxx:104: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::operator=(nsTablesMethod::TM_Matrix&, const nsTablesMethod::TM_Matrix&)’ must be a nonstatic member function
    TM_Util.cxx:114: error: variable or field ‘TablesMethod’ declared void
    TM_Util.cxx:114: error: ‘CLUint’ was not declared in this scope
    TM_Util.cxx:114: error: ‘CLUint’ was not declared in this scope
    TM_Util.cxx: In function ‘void nsTablesMethod::InitMat(nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:127: error: redefinition of ‘void nsTablesMethod::InitMat(nsTablesMethod::TM_Matrix&)’
    TM_Util.h:127: error: ‘void nsTablesMethod::InitMat(nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:131: error: expected ‘;’ before ‘for’
    TM_Util.cxx:131: error: ‘i’ was not declared in this scope
    TM_Util.cxx:131: error: expected ‘;’ before ‘)’ token
    TM_Util.cxx:132: error: ‘j’ was not declared in this scope
    TM_Util.cxx:132: error: expected ‘;’ before ‘)’ token
    TM_Util.cxx: In function ‘nsTablesMethod::TM_Matrix& nsTablesMethod::GenNextMat(const nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:143: error: redefinition of ‘nsTablesMethod::TM_Matrix& nsTablesMethod::GenNextMat(const nsTablesMethod::TM_Matrix&)’
    TM_Util.h:143: error: ‘nsTablesMethod::TM_Matrix& nsTablesMethod::GenNextMat(const nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:145: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘GetWidth’
    TM_Util.cxx:149: error: ‘FillPivotCol’ was not declared in this scope
    TM_Util.cxx:150: error: ‘FillPivotLin’ was not declared in this scope
    TM_Util.cxx:151: error: call of overloaded ‘FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’ is ambiguous
    include/TM_Util.h:87: note: candidates are: void nsTablesMethod::FillRest(nsTablesMethod::TM_Matrix, nsTablesMethod::TM_Matrix)
    TM_Util.h:175: note:                 void nsTablesMethod::FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)
    TM_Util.cxx:145: warning: reference to local variable ‘newMat’ returned
    TM_Util.cxx: In function ‘void nsTablesMethod::FillPivotColumn(nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:157: error: redefinition of ‘void nsTablesMethod::FillPivotColumn(nsTablesMethod::TM_Matrix&)’
    TM_Util.h:157: error: ‘void nsTablesMethod::FillPivotColumn(nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:161: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.cxx:162: error: no match foroperator[]’ in ‘mat[i]’
    TM_Util.cxx:162: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.cxx: In function ‘void nsTablesMethod::FillPivotLine(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:167: error: redefinition of ‘void nsTablesMethod::FillPivotLine(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’
    TM_Util.h:167: error: ‘void nsTablesMethod::FillPivotLine(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:170: error: ‘getPivotLin’ was not declared in this scope
    TM_Util.cxx:170: error: ‘i’ was not declared in this scope
    TM_Util.cxx:171: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.cxx: In function ‘void nsTablesMethod::FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:175: error: redefinition of ‘void nsTablesMethod::FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’
    TM_Util.h:175: error: ‘void nsTablesMethod::FillRest(const nsTablesMethod::TM_Matrix&, nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:179: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.cxx:182: error: ‘const class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.cxx:183: error: no match foroperator[]’ in ‘newMat[i]’
    TM_Util.cxx:183: error: no match foroperator[]’ in ‘oldMat[i]’
    TM_Util.cxx:183: error: no match foroperator[]’ in ‘newMat[i]’
    TM_Util.cxx:183: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotCol’
    TM_Util.cxx:184: error: ‘class nsTablesMethod::TM_Matrix’ has no member named ‘getPivotLin’
    TM_Util.cxx: In function ‘void nsTablesMethod::ShowMat(const nsTablesMethod::TM_Matrix&)’:
    TM_Util.cxx:190: error: redefinition of ‘void nsTablesMethod::ShowMat(const nsTablesMethod::TM_Matrix&)’
    TM_Util.h:190: error: ‘void nsTablesMethod::ShowMat(const nsTablesMethod::TM_Matrix&)’ previously defined here
    TM_Util.cxx:196: error: ‘finalMat’ was not declared in this scope
    TM_Util.cxx:204: error: ‘finalMat’ was not declared in this scope
    TM_Util.cxx:215: error: ‘finalMat’ was not declared in this scope
    virus721@area721m:~/Iut/projects/tables_method2$

    Voici les sources correspondantes :
    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
    ////////////////////////////////////////////////////////////////////
    //                                                                //
    //    FILE   : main.cxx                                           //
    //    AUTHOR : virus721                                           //
    //    NOTES  :                                                    //
    //                                                                //
    ////////////////////////////////////////////////////////////////////
     
    #include "TM_Util.h"
     
    using namespace nsTablesMethod;
     
    int main (int argc, char * argv [])
    {
        TablesMethod (argv[1] /* width */, argv[2] /* height */);
     
        return 0;
     
    } // main()
     
    /* main.cxx */

    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
    ////////////////////////////////////////////////////////////////////
    //                                                                //
    //    FILE     : TM_Util.h                                        //
    //    AUTHOR   : virus721                                         //
    //    NOTES    :                                                  //
    //    LICENCE  : GPL                                              //
    //                                                                //
    ////////////////////////////////////////////////////////////////////
     
    #ifndef __TM_UTIL_H__
    #define __TM_UTIL_H__
     
    #include <vector>
     
    using std::vector;
     
    namespace nsTablesMethod
    {
        #define TM_MINWIDTH   4
        #define TM_MINHEIGHT  4
        #define TM_CASESZ    10 // setw()
     
        typedef long unsigned LUint_t;
        typedef const LUint_t CLUint_t;
        typedef long double Ldouble_t;
     
        typedef vector< Ldouble_t > VLdouble_t;
        typedef vector< VLdouble_t > VVLdouble_t;
     
        //=========================//
        //=== CLASS DEFINITIONS ===//
        //=========================//
     
        class TM_Matrix
        {
          private:
     
            VVLDouble_t m_Matrix;
     
            LUint_t m_PivotCol;
            LUint_t m_PivotLin;
     
            friend TM_Matrix & operator = (TM_Matrix &, TM_Matrix &);
     
          public:
     
            TM_Matrix (CLUint_t & width, CLUint_t & height);
     
            CLUint & getPivotCol (void) const;
            CLUint & getPivotLin (void) const;
     
            void setPivotCol (CLUint_t & col);
            void setPivotLin (CLUint_t & lin);
     
            CLUint_t & getWidth  (void) const;
            CLUint_t & getHeight (void) const;
     
            CLUint_t getPivot (void) const;
     
            /* Returns true is a > 0 element is found */
            bool isSolved (void) const;
     
        }; // TM_Matrix
     
        //=============================//
        //=== FUNCTIONS DEFINITIONS ===//
        //=============================//
     
        TM_Matrix & operator = (TM_Matrix & mat1, const TM_Matrix & mat2);
     
        /* Runs tables method using a widthxheight matrix */
        void TablesMethod (CLUint & width, CLUint & height);
     
        /* Fills matrix with user's values and sets col/lin pivot fields */
        void InitMat (TM_Matrix & emptyMat);
     
        /* Locally creates and returns a new matrix using an old one */
        TM_Matrix & GenNextMat (const TM_Matrix & oldMat);
     
            /* Fills (old?) pivot column in new the matrix */
            void FillPivotColumn (const TM_Matrix & mat);
     
            /* Fills (old?) pivot line in new the matrix */
            void FillPivotLine (const TM_Matrix & oldMat, TM_Matrix & newMat);
     
            /* Fills non previously filled cases in the new matrix */
            void FillRest (const TM_Matrix oldMat, TM_Matrix newMat);
     
        /* Displays the matrix into the standard output */
        void ShowMat (const TM_Matrix & mat);
     
        // #undef TM_MINWIDTH  ?
        // #undef Tm_MINHEIGHT ?
     
    } // nsTablesMethod
     
    #endif
     
    /* TM_Util.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
    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
    ////////////////////////////////////////////////////////////////////
    //                                                                //
    //    FILE     : TM_Util.cxx                                      //
    //    AUTHOR   : virus721                                         //
    //    NOTES    :                                                  //
    //    LICENCE  : GPL                                              //
    //                                                                //
    ////////////////////////////////////////////////////////////////////
     
    #include <iostream>
    #include <vector>
    #include <iomanip>
     
    #include "TM_Util.h"
     
    using std::cout;
    using std::cin;
    using std::endl;
    using std::vector;
    using std::setw;   // setw ?
     
    namespace nsTablesMethod
    {
        //=========================//
        //=== CLASS DEFINITIONS ===//
        //=========================//
     
        TM_Matrix::TM_Matrix (CLUint_t & width, CLUint_t & height)
        {
            VVLdouble_t matrix (0 /* # elements */);
            for (int i = 0; i < width; i++)
                matrix.push_back( VLdouble_t (height) );
            m_Matrix = matrix;
     
        } // TM_Matrix (CLUint_t, CLUint_t)
     
        inline
        CLUint_t & TM_Matrix::getPivotCol (void) const
        {
            return m_PivotCol;
     
        } // GetPivotCol()
     
        inline
        CLUint_t & TM_Matrix::getPivotLin (void) const
        {
            return m_PivotLin;
     
        } // GetPivotLin()
     
        inline
        void TM_Matrix::setPivotCol (CLUint_t & col)
        {
            m_PivotCol = col;
     
        } // setPivotCol (CLUint_t)
     
        inline
        void TM_Matrix::setPivotLin (CLUint_t & lin)
        {
            m_PivotLin = lin;
     
        } // setPivotLin (CLUint_t)
     
        inline
        CLUint & TM_Matrix::getWidth (void) const
        {
            return m_Matrix.size();
     
        } // getWidth()
     
        inline
        CLUint_t & TM_Matrix::getHeight (void) const
        {
            if (m_Matrix.size() == 0)
                return 0;
            else
                return m_Matrix[0].size();
     
        } // getHeight()
     
        inline
        LDouble_t & TM_Matrix::getPivot (void) const
        {
            return m_Matrix [ m_PivotCol /* ? */][ m_PivotLin ];
     
        } // getPivot()
     
        inline
        bool isSolved (void) const
        {
            for (int i = 0; i < getWidth(); i++)
                for (int j = 0; j < getHeight(); j++)
                    if (m_Matrix[i][j] > 0) return false;
            return true;
     
        } // isSolved()
     
        //=============================//
        //=== FUNCTIONS DEFINITIONS ===//
        //=============================//
     
        inline
        TM_Matrix & operator = (TM_Matrix & mat1, const TM_Matrix & mat2)
        {
            mat1.m_Matrix   = mat2.m_Matrix;
            mat1.m_PivotCol = mat2.m_PivotCol;
            mat1.m_PivotLin = mat2.m_PivotLin;
     
            return mat1;
     
        } // operator = (TM_Matrix &, TM_Matrix &)
     
        void TablesMethod (CLUint width, CLUint heigt)
        {
            TM_Matrix matrix (width, height);
     
            InitMat (matrix);
     
            for (int i = 0; matrix.isSolved(); i++)
            matrix = GenNextMat(matrix);
     
            ShowMat(matrix);
     
        } // TablesMethod (CLUint, CLUint)
     
        void InitMat (TM_Matrix & emptyMat)
        {
            cout << "Enter matrix values, line by line. " << endl
     
            for (int i = 0; i < emptyMat.getWidth(); i++)
                for (int j = 0; j < emptyMat.getHeight(); j++)
                    while ()
                      { Ldouble_t value;
                        cin >> value;
                        if ( ! cin.fail() ) break;
                        cout << "Invalid value ! Please enter value again" << endl; }
     
            cout << endl << "Matrix successfully filled" << endl << endl;
     
        } // InitMat (TM_Matrix &)
     
        TM_Matrix & GenNextMat (const TM_Matrix & oldMat)
        {
            TM_Matrix newMat (oldMat.GetWidth(), oldMat.getHeight());
            newMat.setPivotCol(0 /* ?? */);
            newMat.setPivotLin(0 /* ?? */);
     
            FillPivotCol(newMat);
            FillPivotLin(oldMat, newMat);
            FillRest(oldMat, newMat);
     
            return newMat;
     
        } // GenNextMat (const TM_Matrix &)
     
        void FillPivotColumn (TM_Matrix & mat)
        {
            for (int i = 1; i < mat.getWidth(); i++)
            {
                if ( i == mat.getPivotLin() ) continue;
                mat[i][ mat.getPivotCol() ] = 0;
            }
     
        } // FillPivotColumn (TM_Matrix &)
     
        void FillPivotLine (const TM_Matrix & oldMat, TM_Matrix & newMat)
        {
            for (int j = 1; j < oldMat.getWidth() - 1; j++)
                newMat[ getPivotLin() ][i]
                = oldMat[ oldMat.getPivotLin() ][j] / oldMat.getPivot();
     
        } // FillPivotLine (TM_Matrix &, TM_Matrix &)
     
        void FillRest (const TM_Matrix & oldMat, TM_Matrix & newMat)
        {
            for (int i = 1; i < oldMat.getWidth() - 1; i++)
            {
                if (i = oldMat.getPivotLin()) continue;
                for (int j = 1; j < oldMat.getHeight() - 1; j++)
                {
                    if (j = oldMat.getPivotCol()) continue;
                    newMat[i][j] = oldMat[i][j] - newMat[i][newMat.getPivotCol]
                                                * newMat[newMat.getPivotLin()][j];
                }
            }
     
        } // FillRest (TM_Matrix &, TM_Matrix &)
     
        void ShowMat (const TM_Matrix & mat)
        {
            /* Prints top left empty case */
            cout << '|' << setw(TM_CASESZ) << '|';
     
            /* Prints variables */
            for (int i = 1; i < finalMat.getWidth() - 1; i++)
                 cout << setw(TM_CASESZ) << finalMat[0][i] <<'|';
            cout << endl;
     
            /* Prints top right empty case */
            cout << setw(TM_CASESZ) << '|';
     
            /* Prints the rest, excepted last line */
            for (int i = 0; i < finalMat.getWidth(); i++)
            {
                for (int j = 1; i < finalMat.getHeight() -1; j++)
                    cout << '|' << setw(TM_CASESZ) << finalMat[i][j];
                cout << '|' << endl;
            }
     
            /*Prints bottom left empty case */
            cout << setw(TM_CASESZ) << '|';
     
            /* Prints bottom line */
            for (int i = 1; i < finalMat.getWidth(); i++)
                cout << setw(TM_CASESZ) << finalMat[i][finalMat.getHeight() - 1] << '|';
            cout << endl;
     
        } // ShowMat (const TM_Matrix &)
     
    } // nsTablesMethod
     
    /* TM_Util.cxx */
    Voila merci de m'avoir lu et merci a deux qui me répondront ! Désolé pour le code pas beau mais le forum enlève tout les espaces en trop

  2. #2
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 129
    Billets dans le blog
    149
    Par défaut
    Bonjour,

    Pensez à utiliser les balises 'quote' pour les erreurs du compilateur. Enfin je crois que c'est mieux avec.
    Sinon, pour les erreurs du compilateur, il faut commencer par les premières:
    include/TM_Util.h:38: error: ‘VVLDouble_t’ does not name a type
    Qui veut simplement dire que 'VVLDouble_t' n'est pas reconnu.
    En fait, en enlever les premières erreurs, beaucoup vont disparaitre par magie .

    Je vous laisse continuer l'investigation .
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 21
    Par défaut
    Merci pour ta réponse ! L'ennui c'est que je ne sais pas d'ou viennent ces pettes boulettes qui en créent d'autres ! Qu'est-ce qu'il a de pas bien mon typedef ?

  4. #4
    Inactif  


    Homme Profil pro
    Inscrit en
    Novembre 2008
    Messages
    5 288
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Secteur : Santé

    Informations forums :
    Inscription : Novembre 2008
    Messages : 5 288
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    typedef vector< VLdouble_t > VVLdouble_t;
    VVLDouble_t m_Matrix;
    Erreur de syntaxe

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 21
    Par défaut
    Ah okay merci !
    Je vais tout re regarder caractère par caractère x)

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 21
    Par défaut
    Re ! Voila j'ai revérifié un peu les majucules et les _t et ca m'a enlevé pas mal d'erreurs ! Mais il me reste encore un problème : surcharger l'opérateur [] (et le = aussi ! ). J'ai un objet qui contient une matrice (vecteur de vecteur de long double), et deux entiers (long unsigned). J'aimerai pouvoir utiliser les [] sur ces objets (matrice[x][y] par exemple), mais je ne sais pas comment surcharger l'opérateur [].
    Dois-le mettre dans la classe avec un seul paramètre (l'indice), ou dois-je me mettre hors de la classe avec deux parametres (objet contenant la matrice, indice) et rajouter friend operator dans la classe ? (partie publique ou pirvée d'aileurs ?). J'ai essayer de le surchager mais j'ai plein d'erreurs partout je ne sais pa comment faire :'( Tout aide serait bienvenue !
    Merci d'avance !

Discussions similaires

  1. CMake projet C/C++, problème de liens entre les fichiers
    Par LaMainSurLeKatana dans le forum C++
    Réponses: 1
    Dernier message: 16/08/2010, 15h53
  2. Réponses: 3
    Dernier message: 02/07/2010, 15h50
  3. [MySQL] Problème de liens entre les pages
    Par feldi dans le forum PHP & Base de données
    Réponses: 32
    Dernier message: 29/06/2010, 14h07
  4. Labyrinthe : problème de lien entres les cases
    Par spax dans le forum Prolog
    Réponses: 3
    Dernier message: 20/12/2006, 16h05
  5. lien entre les table de paradox
    Par salim_intic1 dans le forum Bases de données
    Réponses: 2
    Dernier message: 13/05/2004, 16h00

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