C++ Klassenhierachie Fehler beim Kompilieren

Bin derzeit dabei mir C++ beizubringen. Bei einer Aufgabe zum Thema Vererbung, soll ich 2 Klassen(GiroKonto, SparKonto) von Konto ableiten, und paar kleine Werte/Funktionen hinzufügen.

Code:
/*
 * Konto.h
 *
 *  Created on: 08.07.2011
 *      Author: snow
 */

#ifndef KONTO_H_
#define KONTO_H_
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

class Konto{

private:
    string k_name;
    unsigned long k_nr;
    double k_stand;

public:
    Konto(const string& name = "Unbekannt", unsigned long nr = 1111111L, double stand = 0.0){
        k_name =  name;
        k_nr = nr;
        k_stand = stand;
    }
    virtual ~Konto(){}

    const string& getName() const {return k_name;}
    void setName(const string& s){ k_name = s;}

    long getNr() const {return k_nr;}
    void setNr(long nr){k_nr = nr;}

    double getStand() const {return k_stand;}
    void setStand(double s){k_stand = s;}


    void display() const;

    ostream& write(ostream& os) const;
    istream& read(istream& is);

};


#endif

/*
 * Konto.cpp
 *
 *  Created on: 08.07.2011
 *      Author: snow
 */
#include "Konto.h"

using namespace std;





void Konto::display() const{
    cout<< "Inhaber: " << k_name << endl
        << "Kontonummer: " << k_nr << endl
        << "Stand: "<< k_stand << endl;

}


ostream& Konto::write(ostream& os) const{
    os << name << '\0';
    os.write((char*)&nr,sizeof(nr));
    os.write((char*)&stand, sizeof(stand));
    return os;
}

istream& Konto::read(istream& is){
    getline(is, name, '\0');
    is.read( (char*)&nr, sizeof(nr));
    is.read( (char*)&stand, sizeof(stand));
    return is;
}

/*
 * GiroKonto.h
 *
 *  Created on: 15.07.2011
 *      Author: snow
 */

#ifndef GIROKONTO_H_
#define GIROKONTO_H_

#include "Konto.h"

class GiroKonto : public Konto {

private:
    double limit;
    float sollzins;

public:
    GiroKonto(double l = 1000.00, float sz = 00.4F, const string& name = "Unbekannt", unsigned long nr = 1111111L, double stand = 0.0);
    ~GiroKonto(){}

    void setLimit(double l){ limit = l;}
    double getLimit() const{ return limit;}

    void setZins(float sz){ sollzins = sz;}
    float getZins() const{ return sollzins;}

    void display() const;

};

#endif /* GIROKONTO_H_ */

/*
 * GiroKonto.cpp
 *
 *  Created on: 15.07.2011
 *      Author: snow
 */

#include "GiroKonto.h"
#include "Konto.h"
using namespace std;

GiroKonto::GiroKonto(double l, float sz, const string& name, unsigned long nr, double stand)
    : Konto(name, nr, stand), limit(l), sollzins(sz) {
    ;

}

void GiroKonto::display() const{
    Konto::display();

    cout << "Überziehungslimit: " << limit << endl;
    cout << "Sollzins: " << sollzins << endl;


}

/*
 * SparKonto.cpp
 *
 *  Created on: 15.07.2011
 *      Author: snow
 */

#include "SparKonto.h"
#include "Konto.h"

SparKonto::SparKonto(float z, const string& name, unsigned long nr , double stand )
    : Konto(name, nr, stand), zins(z){
    ;
}


void SparKonto::display() const{
    Konto::display();

    cout << "Habenzinssatz: " << zins << endl;
}

/*
 * SparKonto.h
 *
 *  Created on: 15.07.2011
 *      Author: snow
 */

#ifndef SPARKONTO_H_
#define SPARKONTO_H_

#include "Konto.h"


class SparKonto : public Konto {

private:
    float zins;

public:
    SparKonto(float z = 0.02F, const string& name = "Unbekannt", unsigned long nr = 1111111L, double stand = 0.0);
    ~SparKonto(){}

    void setZins(float z){ zins = z;}
    float getZins() const{ return zins;}



    void display() const;
};

#endif /* SPARKONTO_H_ */

/*
 * konto_test.cpp
 *
 *  Created on: 15.07.2011
 *      Author: snow
 */

#include "Konto.h"
#include "GiroKonto.h"
#include "SparKonto.h"

int main(int argc, char *argv[]){
    GiroKonto giro;
    SparKonto spar;

    giro.display();

    spar.display();

    return 0;
}
Der Compiler gibt mir folgende Fehlermeldung:
Code:
snow@host:~/Code/LuPanwenden/Aufgaben$ g++ -o konto_test konto_test.cpp SparKonto.cpp GiroKonto.cpp
/tmp/ccIlAwhQ.o: In function `SparKonto::display() const':
SparKonto.cpp:(.text+0x66): undefined reference to `Konto::display() const'
/tmp/ccaa3jxM.o: In function `GiroKonto::display() const':
GiroKonto.cpp:(.text+0x76): undefined reference to `Konto::display() const'
collect2: ld returned 1 exit status

Also in kurz:
Giro/Spar-Konto erben Konto. Konto besitzt eine Methode
Code:
void display() const;
In GiroKonto redifinier ich
Code:
void display() const;
und will in dieser Methode per
Code:
Konto::display();
das "alte display() aufrufen, worauf mir der Compiller eine Fehlermeldung gibt.
Leider kann ich nicht nachvollziehen wo das Problem liegt...
Vielleicht kann mir ja wer weiterhelfen :)
 
Konto::display() hast du in Konto.cpp definiert, aber die gibst du g++ nicht mit. Daher findet er die Methode beim linken nicht.
 
Zurück
Oben