009
09.04.2016, 12:35 Uhr
Tetje
|
Triple.cpp:
C++: |
#include "Triple.h"
#ifndef Triple_CPP
#define Triple_CPP
//ctor template<typename type_x, typename type_y, typename type_z> Triple<type_x, type_y, type_z>::Triple() : Pair<type_x, type_y>(), third(t) {};
template<typename type_x, typename type_y, typename type_z> Triple<type_x, type_y, type_z>::Triple(type_x f, type_y s, type_y t) : Pair<type_x, type_y>(f, s), third(static_cast<type_z>(0)) {};
//getter template<typename type_x, typename type_y, typename type_z> type_z Triple<type_x, type_y, type_z>::getThird() const { return third; }
//basic comparator template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator ==(const Triple<type_x, type_y, type_z>& secondTriple) { return ((getFirst() == secondTriple.getFirst()) && (getSecond() == secondTriple.getSecond()) && (getThird() == secondTriple.getThird())); }
template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator<(const Triple<type_x, type_y, type_z>& secondTriple) { return ((getFirst() <= secondTriple.getFirst()) && (getSecond() <= secondTriple.getSecond()) && (getThird() < secondTriple.getThird())); }
//derived comparators template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator !=(const Triple<type_x, type_y, type_z>& secondTriple) { return (!(*this == secondTriple)); }
template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator <=(const Triple<type_x, type_y, type_z>& secondTriple) { return ((*this < secondTriple) || (*this == secondTriple)); }
template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator >(const Triple<type_x, type_y, type_z>& secondTriple) { return (!(*this <= secondTriple)); }
template<typename type_x, typename type_y, typename type_z> bool Triple<type_x, type_y, type_z>::operator >=(const Triple<type_x, type_y, type_z>& secondTriple) { return (!(*this < secondTriple)); }
#endif
|
Testtreiber:
C++: |
#include "Pair.h" #include ".\..\Triple\Triple.h"
#include <iostream> #include <iomanip>
using namespace std;
int main() {
Pair<> pair1{ 1, 1 }; Pair<> pair2{ 1, 2 };
Triple<> triple1{ 1, 1, 1 }; Triple<> triple2{1, 1, 2};
cout << "pair1 == pair2" << setw(10) << (pair1 == pair2) << endl; cout << "pair2 < pair2" << setw(10) << (pair1 < pair2) << endl; cout << "pair2 > pair2" << setw(10) << (pair1 > pair2) << endl;
cout << "pair1 == triple1" << setw(10) << (pair1 == triple1) << endl; cout << "pair1 == triple2" << setw(10) << (pair1 == triple2) << endl;
cout << "triple1 == triple2" << setw(10) << (triple1 == triple2) << endl; cout << "triple1 < triple2" << setw(10) << (triple1 < triple2) << endl; cout << "triple1 > triple2" << setw(10) << (triple1 > triple2) << endl;
}
|
So man sehen Visual Studio wirft die selbe Fehlermeldung wie immer:
Zitat: |
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand Fehler C2143 Syntaxfehler: Es fehlt "," vor "<" ..\triple\triple.h 8
|
Die Fehlermeldung des g++ sieht sehr ähnlich aus:
Zitat: |
||=== Build: Debug Win32 in Pair_Triple (compiler: GNU GCC Compiler) ===| .\..\Triple.h|8|error: expected template-name before '<' token| .\..\Triple.h|8|error: expected '{' before '<' token| .\..\Triple.h|8|error: expected unqualified-id before '<' token| .\..\Triple.cpp|9|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\Triple.cpp|12|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\Triple.cpp|16|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\Triple.cpp|22|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\Triple.cpp|29|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\riple.cpp|39|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\Triple.cpp|44|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| .\..\riple.cpp|49|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| C:\Users\Sebastian\Documents\Programmierung\C++ - Arduino\Triple\Triple.cpp|54|error: invalid use of incomplete type 'class Triple<type_x, type_y, type_z>'| .\..\Triple.h|8|error: declaration of 'class Triple<type_x, type_y, type_z>'| ||=== Build failed: 21 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
|
Das sind ganze 21 Fehler, aber die meisten Hängen wohl vom den ersten Paar Fehlermeldungen ab, die ähnlich auschauen, wie der von visual Studio...
https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=DE-DE&k=k%28C2143%29&rd=true
Aber was mir davon helfen soll, weiß ich nicht, habe die gesamte Seite durchgearbeitet und ich weiß nicht, wie mir das weiter hilft. Habe mal einfach ein paar Sachen ausprobiert und es wurde eher schlimmer... |