Warum funktioniert folgendes nicht??
functions.cpp
functions.h
ich bekomm da ne Fehlermeldung aus der ich nicht ganz schlau werde.
Die Signaturen sind doch unterschiedlich, also müsste der Kompiler doch zwischen den Überladungen unterscheiden können...
Grüsse,
Matze
functions.cpp
Code:
...
// wert fuer wert multiplizieren
std::vector<double> operator*(std::vector<double>& a, std::vector<double>& b) {
std::vector<double> c;
for(std::vector<double>::const_iterator ita = a.begin(), itb = b.begin(); ita < a.end(), itb < b.end(); ita++, itb++) {
c.push_back((*ita)*(*itb));
}
return c;
}
// Skalar mit einem Vektor multiplizieren
std::vector<double> operator*(double& a, std::vector<double>& b) {
std::vector<double> c;
for(std::vector<double>::const_iterator it = b.begin(); it < b.end(); it++) {
c.push_back((*it)*a);
}
return c;
}
// Skalarprodukt von zwei Vektoren
double operator*(std::vector<double>& a, std::vector<double>& b) {
double temp = 0;
for(std::vector<double>::const_iterator ita = a.begin(), itb = b.begin(); ita < a.end(), itb < b.end(); ita++, itb++) {
temp = temp + *ita * *itb;
}
return temp;
}
...
functions.h
Code:
...
std::vector<double> operator*(std::vector<double>&, std::vector<double>&);
std::vector<double> operator*(double&, std::vector<double>&);
double operator*(std::vector<double>&, std::vector<double>&);
...
ich bekomm da ne Fehlermeldung aus der ich nicht ganz schlau werde.
sammy@uranos > make
building functions.o
functions.h:21: error: new declaration 'double operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
functions.h:19: error: ambiguates old declaration 'std::vector<double, std::allocator<double> > operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
functions.cpp: In function 'std::vector<double, std::allocator<double> > operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)':
functions.cpp:80: error: new declaration 'std::vector<double, std::allocator<double> > operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
functions.h:21: error: ambiguates old declaration 'double operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
functions.cpp: In function 'double operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)':
functions.cpp:102: error: new declaration 'double operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
functions.cpp:80: error: ambiguates old declaration 'std::vector<double, std::allocator<double> > operator*(std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&)'
make: *** [functions.o] Error 1
Die Signaturen sind doch unterschiedlich, also müsste der Kompiler doch zwischen den Überladungen unterscheiden können...
Grüsse,
Matze