Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (ANSI-Standard) » Problem mit Element in vector

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
07.11.2006, 10:59 Uhr
derphilipder



Ich peils nicht...
Was für Gründe kann es haben, daß das

C++:
Taetigkeit t = activitys[index];
t.Start(QTime::currentTime());
act_over_time.push_back(t);

einen anderen Effekt hat als das

C++:
act_over_time.push_back(activitys[index]);
(act_over_time.end())->Start(QTime::currentTime());


Im zweiten Fall hat die Methode Start nicht den gewünschten Effekt.
--
Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!"
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
07.11.2006, 11:20 Uhr
ao

(Operator)


Was enthält act_over_time? Objekte vom Typ Taetigkeit oder Referenzen auf Taetigkeit?

Falls es Objekte sind, wird die in push_back übergebene Instanz kopiert und ist nicht identisch mit activitys[index].

ao
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
07.11.2006, 13:35 Uhr
derphilipder



Nein, ist keine Referenz.
Das heißt das Problem ist beim entsprechenden Kopierkonstruktor zu suchen?!
--
Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!"
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
003
07.11.2006, 13:52 Uhr
Th



Was für eine Klasse hat 'act_over_time'? Ich tippe auf std::vector !?
Dann zeigt act_over_time.end() nicht auf das zuletzt eingefügte Element, sondern auf ein Element dahinter. Du mußt act_over_time.back() dafür verwenden!!!
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
004
07.11.2006, 16:14 Uhr
derphilipder



Jo, hast recht! Thx!
--
Konfuzius says: "A man who goes to bed with an itchy asshole is a man who wakes up with stinky finger!"
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (ANSI-Standard) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: