[c++]Linker Error

mcyonx

Grünschnabel
Hallo!

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

Code:
  [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
 
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 :)
 
Die Klasse Matrix sieht wie folgt aus:

Code:
#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:
#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
 
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^^
 
Zurück