[g++] undefined reference to

sammy2ooo

voll Tohuwabohu
Hallo Leute,

ich versuche gerade ein einfaches Programm zu kompilieren aber erhalte immer folgende Fehlermeldung

sammy@uranos > g++ -Wall 4-0.cpp
/tmp/ccLzuTKT.o: In function `main':
4-0.cpp:(.text+0x106): undefined reference to `lese(std::basic_istream<char, std::char_traits<char> >&, student_info&)'
collect2: ld returned 1 exit status

4-0.cpp
Code:
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>

//#include "endnote.h"
#include "student_info.h"

using std::cin;
using std::cout;
using std::domain_error;
using std::endl;
using std::max;
using std::setprecision;
using std::sort;
using std::streamsize;
using std::string;
using std::vector;

int main() {
        vector<student_info> studenten;
        student_info datensatz;
        string::size_type maxlaenge = 0;

        while(lese(cin, datensatz)) {
                maxlaenge = max(maxlaenge, datensatz.name.size());
                studenten.push_back(datensatz);
        }

        return 0;
}

student_info.h
Code:
sammy@uranos > cat student_info.h                                                                                  
#ifndef student_info_h
#define student_info_h

#include <iostream>
#include <string>
#include <vector>

struct student_info {
       std::string name;
       double vdiplom, diplom;
       std::vector<double> hausarbeiten;
};

bool vergleiche(const student_info&, const student_info&);
std::istream& lese(std::istream&, student_info&);
std::istream& lese_ha(std::istream&, std::vector<double>&);
#endif

student_info.cpp
Code:
sammy@uranos > cat student_info.cpp                                                                                    
#include "student_info.h"

using std::istream;
using std::vector;

bool vergleiche(const student_info& x, const student_info& y) {
        return x.name < y.name;
}

istream& lese(istream& is, student_info& s) {
        is >> s.name >> s.vdiplom >> s.diplom;
        lese_ha(is, s.hausarbeiten);

        return is;
}

istream& lese_ha(istream& in, vector<double>& ha) {
        if(in) {
                ha.clear();
                double x;

                while(in >> x)
                        ha.push_back(x);

                in.clear();
        }

        return in;
}

sammy@uranos > g++ --version
g++ (GCC) 4.1.1 (Gentoo 4.1.1-r3)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Wo liegt der Fehler????
 
Besser: jede Source-Datei einzeln kompilieren und dann die object files linken

Noch besser: genau das mit einem Makefile machen

auf bald
oenone
 
Zurück
Oben