tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
3
ZUGRIFFE
698
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    mcyonx mcyonx ist offline Rookie
    Registriert seit
    Dec 2007
    Beiträge
    8
    Hallo!

    Ich versuche im Moment ein Programm, was Matizen berechnet zum compilieren. Dec-Ccp gibt mit aber immer folgende Fehlermeldung aus:

    Code :
    1
    
      [Linker error] undefined reference to `matrix::hoehe() const'

    Die Klasse Matrix.h habe ich erste und im Dev-Ccp Ordner gespeichert. Hab schon nach dem Fehler gegoogelt aber nichts brauchbares finden können.

    Bin für jede Hilfe dankbar.

    Gruß
    mcyonx
     

  2. #2
    GillBates GillBates ist offline Mitglied Silber
    Registriert seit
    Oct 2007
    Ort
    BW
    Beiträge
    69
    könntest du mal etwas Code posten? z. B. in dem 'matrix' vorkommt?

    Die fehlermeldung sieht aus als hättest du eine Klasse namens 'matrix', in der eine Funktion 'hoehe()' ist.
    Stimmen die Deklarationen?

    Wie schon gesagt, ohne Code wird dir wohl niemand helfen können.


    grüssle
     
    GillBates


    Hab' gerade einen Intel und einen AMD aus dem 3. Stock geworfen ... der AMD war tatsächlich schneller!

    [X] <-- Nail here for new Monitor

  3. #3
    mcyonx mcyonx ist offline Rookie
    Registriert seit
    Dec 2007
    Beiträge
    8
    Die Klasse Matrix sieht wie folgt aus:

    Code :
    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
    
    #ifndef __MATRIX_H
    #define __MATRIX_H
    #include <stdio.h>
    #include <stdlib.h>
     
    class matrix
    {
    public:
        matrix(int,int);                             // Konstruktor
        matrix(const matrix&);                             // Copy-Konstruktor
        ~matrix();                                   // Destruktor 
        int &operator () (int,int);                  // liefert Referenz auf das Element
        int get_element (int,int) const;             // Elementzugriff lesen
        void set_element (int,int,int);              // Elementzugriff schreiben
        int breite() const;                          // spaltenzahl
        int hoehe() const;                           // zeilenzahl 
            
    private:
        int spalten;
        int zeilen; 
        int *lineares_feld;
    };
     
     
    matrix operator + (const matrix &, const matrix &);
    matrix operator - (const matrix &, const matrix &);
    matrix operator * (const matrix &, const matrix &);
     
    #endif

    Das Programm selber so:

    Code :
    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
    
    #include "matrizen.h"
    #include <iostream>
     
    //       Matrizenausgabe
    using namespace std;
    void ausgabe(const matrix &a)
    {
         cout << endl << endl;
         for (int i=0; i<a.hoehe(); i++)
         {     
              for (int j=0 ; j<a.breite(); j++)
          {
                  cout << a.get_element(j,i) << '\t';
              };
          cout << endl;
         };
         cout << endl;
    };
     
    //     Matrizeneingabe
     
    void eingabe(matrix &a)
    {
         cout << endl << endl;
         for (int i=0; i<a.hoehe(); i++)
         {     
              cout << "\n" << i << ". Zeile: \n";
              for (int j=0 ; j<a.breite(); j++)
          {
                  cout << "    " << j << ". Spalte: ";
                  cin >> a(j,i);
              };
          cout << endl;
         };
         cout << endl;
    };
     
     
    //
    //    Testprogramm fuer die Matrizenoperatoren:
    //
     
    int main()
    {
        int zl; //zeile
        int sp; //spalte
        cout << "\n\nHallo!\nHast Du Lust, zwei Matrizen einzugeben\?\n";
     
        cout << "\nSpalten: ";
        cin >> sp;
        cout << "Zeilen:  ";
        cin >> zl;
        matrix a(sp,zl);
     
        cout << "\nSpalten: ";
        cin >> sp;
        cout << "Zeilen:  ";
        cin >> zl;
        matrix b(sp,zl);
     
        cout << "\nMatrix A:";
        ausgabe(a);
        cout << "\nMatrix B:";
        ausgabe(b);
     
        char wahl='\0';
        cout << "\nQ Quit   + (C=A+B)   - (C=A-B)   * (C=A*B)   "
                "\nA A.Elemente aendern   B B.Elemente aendern   W Werte anzeigen";
        cout << "\n\nBitte Geben Sie Ihre Wahl Ein: ";
        cin >> wahl;
        while ((wahl!='Q') && (wahl!='q'))
        {
              switch (wahl)
          {
          case 'A':
          case 'a': eingabe(a); break;
              case 'B':
              case 'b': eingabe(b); break;
          case 'W':
              case 'w': cout << "\nA:"; ausgabe(a); cout << "\nB:"; ausgabe(b); break;  
              case '+': cout << "\nC:"; ausgabe(a+b); break;
              case '-': cout << "\nC:"; ausgabe(a-b); break;
              case '*': cout << "\nC:"; ausgabe(a*b); break;
              default : cout << "\n\?\n";  
              };
     
          cout << "\nQ Quit   + (C=A+B)   - (C=A-B)   * (C=A*B)   "
                      "\nA A.Elemente aendern   B B.Elemente aendern   W Werte anzeigen";
          cout << "\n\nBitte Geben Sie Ihre Wahl Ein: ";
          cin >> wahl;
        };
    };

    Gruß mcyonx
     

  4. #4
    Avatar von Ryu1991
    Ryu1991 Ryu1991 ist offline Mitglied Gold
    Registriert seit
    Dec 2007
    Beiträge
    241
    Ich würde sagen das sieht stark danach aus, dass du vergessen hast die Matrix.cpp in der die Funktionen des Headers implementiert sind, einzubinden
     

Ähnliche Themen

  1. Linker error
    Von rojeroje im Forum C/C++
    Antworten: 2
    Letzter Beitrag: 22.09.09, 20:09
  2. Linker Error
    Von Sek77 im Forum C/C++
    Antworten: 1
    Letzter Beitrag: 02.04.08, 18:36
  3. [Dev-C++] Linker Error, was ist zu tun?
    Von meilon im Forum C/C++
    Antworten: 2
    Letzter Beitrag: 09.08.06, 11:10
  4. Linker error
    Von Sotares im Forum C/C++
    Antworten: 4
    Letzter Beitrag: 12.11.05, 23:25
  5. Linker Error
    Von paddymann im Forum C/C++
    Antworten: 13
    Letzter Beitrag: 21.07.05, 12:47