Probleme mit Vektoren
-
Hallo,
immer wenn ich eine Struktur als Vektor definieren will erhalte ich sehr viele Fehlermeldungen. Wenn ich aber einen ganz normalen Datentyp definiere erhalte ich keine. ist es irgenwie möglich eine Struktur in einem Vektor zu definieren.
Ich nutze übrigens MinGW als Compiler und arbeite mit der Ultimate ++ GUI.
[cpp]
Vector<int> test; //keine Fehlermeldungen
Vector<Struktur> test; //Fehlermeldungen
[cpp]Hier mal die Fehler beim Kompilieren:
----- CtrlLib ( GUI GCC DEBUG BLITZ WIN32 ) (1 / 9)
----- CtrlCore ( GUI GCC DEBUG BLITZ WIN32 ) (2 / 9)
----- RichText ( GUI GCC DEBUG BLITZ WIN32 ) (3 / 9)
----- Draw ( GUI GCC DEBUG BLITZ WIN32 ) (4 / 9)
----- Core ( GUI GCC DEBUG BLITZ WIN32 ) (5 / 9)
----- plugin/bmp ( GUI GCC DEBUG BLITZ WIN32 ) (6 / 9)
----- plugin\z ( GUI GCC DEBUG BLITZ WIN32 ) (7 / 9)
----- plugin\png ( GUI GCC DEBUG BLITZ WIN32 ) (8 / 9)
objects.cpp
main.cpp
C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h: In functionvoid Upp::AssertMoveable0(T*) [with T = objects::s_lines]': C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h:223: instantiated fromvoid Upp::AssertMoveable(T*) [with T = objects::s_lines]'
C:/Program Files/Ultimate pp/uppsrc/Core/Vcont.h:85: instantiated from `Upp::Vector<T>::~Vector() [with T = objects::s_lines]'
C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h:214: error: no match for 'operator*' in '*t'
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: candidates are: Upp::Size_<int> Upp::operator(Upp::Size_<int>, Upp::Size_<int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<int> Upp::operator*(Upp::Size_<int>, int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<int> Upp::operator*(int, Upp::Size_<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_<short int> Upp::operator*(Upp::Size_<short int>, Up
p::Size_<short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<short int> Upp::operator*(Upp::Size_<short int>, sh
ort int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<short int> Upp::operator*(short int, Upp::Size_<sho
rt int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_<double> Upp::operator*(Upp::Size_<double>, Upp::Siz
e_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<double> Upp::operator*(Upp::Size_<double>, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<double> Upp::operator*(double, Upp::Size_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_Upp::int64 Upp::operator*(Upp::Size_Upp::int64,
Upp::Size_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_Upp::int64 Upp::operator*(Upp::Size_Upp::int64,
long long int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_Upp::int64 Upp::operator*(long long int, Upp::Size
Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point<int> Upp::operator*(Upp::Point_<int>, Upp::Point_
<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<int> Upp::operator*(Upp::Point_<int>, int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<int> Upp::operator*(int, Upp::Point_<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_<short int> Upp::operator*(Upp::Point_<short int>,
Upp::Point_<short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<short int> Upp::operator*(Upp::Point_<short int>,
short int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<short int> Upp::operator*(short int, Upp::Point_<
short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_<double> Upp::operator*(Upp::Point_<double>, Upp::
Point_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<double> Upp::operator*(Upp::Point_<double>, doubl
e)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<double> Upp::operator*(double, Upp::Point_<double
)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_Upp::int64 Upp::operator*(Upp::Point_<Upp::int64
, Upp::Point_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_Upp::int64 Upp::operator*(Upp::Point_<Upp::int64
, long long int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_Upp::int64 Upp::operator*(long long int, Upp::Po
int_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:610: note: Upp::Sizef Upp::operator*(Upp::Size, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:611: note: Upp::Sizef Upp::operator*(double, Upp::Size)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:613: note: Upp::Sizef Upp::operator*(Upp::Size, Upp::Sizef)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:614: note: Upp::Sizef Upp::operator*(Upp::Sizef, Upp::Size)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:645: note: Upp::Sizef Upp::operator*(Upp::Size16, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:646: note: Upp::Sizef Upp::operator*(double, Upp::Size16)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:648: note: Upp::Sizef Upp::operator*(Upp::Size16, Upp::Sizef)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:649: note: Upp::Sizef Upp::operator*(Upp::Sizef, Upp::Size16)
C:/Program Files/Ultimate pp/uppsrc/Core/Color.h:75: note: Upp::RGBA Upp::operator*(int, Upp::Color)
C:/Program Files/Ultimate pp/uppsrc/RichText/RichText.h:33: note: int Upp::operator*(int, Upp::Zoom)
C:/Program Files/Ultimate pp/uppsrc/RichText/RichText.h:51: note: Upp::Size Upp::operator*(Upp::Zoom, Upp::Size)
/Gtypes.h:141: note: Upp::Point_Upp::int64 Upp::operator*(long long int, Upp::Point_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:610: note: Upp::Sizef Upp::operator*(Upp::Size, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:611: note: Upp::Sizef Upp::operator*(double, Upp::Size)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:613: note: Upp::Sizef Upp::operator*(Upp::Size, Upp::Sizef)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:614: note: Upp::Sizef Upp::operator*(Upp::Sizef, Upp::Size)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:645: note: Upp::Sizef Upp::operator*(Upp::Size16, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:646: note: Upp::Sizef Upp::operator*(double, Upp::Size16)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:648: note: Upp::Sizef Upp::operator*(Upp::Size16, Upp::Sizef)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:649: note: Upp::Sizef Upp::operator*(Upp::Sizef, Upp::Size16)
C:/Program Files/Ultimate pp/uppsrc/Core/Color.h:75: note: Upp::RGBA Upp::operator*(int, Upp::Color)
C:/Program Files/Ultimate pp/uppsrc/RichText/RichText.h:33: note: int Upp::operator*(int, Upp::Zoom)
C:/Program Files/Ultimate pp/uppsrc/RichText/RichText.h:51: note: Upp::Size Upp::operator*(Upp::Zoom, Upp::Size)
C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h: In functionvoid Upp::AssertMoveable0(T*) [with T = objects::s_lines]': C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h:223: instantiated fromvoid Upp::AssertMoveable(T*) [with T = objects::s_lines]'
C:/Program Files/Ultimate pp/uppsrc/Core/Vcont.h:85: instantiated from `Upp::Vector<T>::~Vector() [with T = objects::s_lines]'
C:/Program Files/Ultimate pp/uppsrc/Core/Topt.h:214: error: no match for 'operator*' in 't'
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: candidates are: Upp::Size_<int> Upp::operator(Upp::Size_<int>, Upp::Size_<int
)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<int> Upp::operator(Upp::Size_<int>, int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<int> Upp::operator*(int, Upp::Size_<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_<short int> Upp::operator*(Upp::Size_<short int>, Up
p::Size_<short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<short int> Upp::operator*(Upp::Size_<short int>, sh
ort int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<short int> Upp::operator*(short int, Upp::Size_<sho
rt int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_<double> Upp::operator*(Upp::Size_<double>, Upp::Siz
e_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_<double> Upp::operator*(Upp::Size_<double>, double)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_<double> Upp::operator*(double, Upp::Size_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:38: note: Upp::Size_Upp::int64 Upp::operator*(Upp::Size_Upp::int64,
Upp::Size_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:39: note: Upp::Size_Upp::int64 Upp::operator*(Upp::Size_Upp::int64,
long long int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:40: note: Upp::Size_Upp::int64 Upp::operator*(long long int, Upp::Size
Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point<int> Upp::operator*(Upp::Point_<int>, Upp::Point_
<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<int> Upp::operator*(Upp::Point_<int>, int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<int> Upp::operator*(int, Upp::Point_<int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_<short int> Upp::operator*(Upp::Point_<short int>,
Upp::Point_<short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<short int> Upp::operator*(Upp::Point_<short int>,
short int)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<short int> Upp::operator*(short int, Upp::Point_<
short int>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_<double> Upp::operator*(Upp::Point_<double>, Upp::
Point_<double>)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_<double> Upp::operator*(Upp::Point_<double>, doubl
e)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:141: note: Upp::Point_<double> Upp::operator*(double, Upp::Point_<double
)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:139: note: Upp::Point_Upp::int64 Upp::operator*(Upp::Point_<Upp::int64
, Upp::Point_Upp::int64)
C:/Program Files/Ultimate pp/uppsrc/Core/Gtypes.h:140: note: Upp::Point_Upp::int64 Upp::operator*(Upp::Point_<Upp::int64
, long long int)
-
Welche Vector-Klasse benutzt du denn?
Und wie sieht deine Struktur aus?
-
Ich hatte noch nie ein Problem damit, zeig doch mal deine Struktur. Wenn dein Compiler nicht mal
#include <vector> struct abc { int x; }; .. std::vector<abc> vec;akzeptiert, würde ich mich nach einem anderen umsehen..
-
Naja, er benutzt Upp::Vector.
-
Meine Struktur sieht so aus:
struct s_lines { Point p1; Point p2; Color color; int width; };
-
Habe das jetzt mit std::vector hinbekommen. Jetzt habe ich nur noch eine grundlegende Frage. Wenn ich etwas mit push_back() hinzufüge dann gebe ich ja den Wert, welchen ich hinzufügen möchte, in den Klammern an. Wie mache ich das dann wenn ich eine Struktur übergeben möchte.
-
gm1988 schrieb:
Wenn ich etwas mit push_back() hinzufüge dann gebe ich ja den Wert, welchen ich hinzufügen möchte, in den Klammern an. Wie mache ich das dann wenn ich eine Struktur übergeben möchte.
Genauso.
-
Hätte ich eigentlich selbst drauf kommen müssen. Funktioniert jetzt. Danke an alle für die Hilfe.