Devi essere molto stanco. leggi qui
"memorizzare nel vector non gli oggetti ma puntatori ad essi"
Devi essere molto stanco. leggi qui
"memorizzare nel vector non gli oggetti ma puntatori ad essi"
Happiness in intelligent people is the rarest thing I know.
Ci sto dietro da stamani praticamente non stop, fai due conti tu t_t
Domani ci riguardo mo veramente basta perchè ha iniziato a darmi un'errore strano e son tipo 30 minuti che guardo lo schermo senza capire da dove provenga una cosa del genere se io la classe che mo da errore non l'ho sfiorata manco con un dito t_t
domani t_T
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Provato ma non me lo fa fare. La pagina di wiki che mi hai linkato (e ieri sera manco me ne ero accorto rotfl) dice che per far si che il riallocamento del vector sia più veloce e meno oberante dal punto di vista computazionale/temporale conviene passare al vector il puntatore invece che l'oggetto in se.. ed è quello che faccio io, ti copio il codice della dichiarazione e dell'assegnamento.
vector<parallelepiped*> parals;
...
...
...
parallelepiped* paral = new parallelepiped(name, floor);
parals.push_back(paral).
Se faccio come hai detto tu, dichiarando quindi un vettore così:
vector<parsedObject*> objects;
me lo mette senza problemi nel vettore, ma poi quando vado a reperire il dato non me lo reperisce più come parallelepiped bensì come parsedObject.
Ah ovviamente parsedObject è padre, parallelepiped è figlio.
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Happiness in intelligent people is the rarest thing I know.
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
parallelepiped* punt = (parallelepiped*)objects.get(i);
ovviamente ti da parsedObject, contiene proprio quelli, e cmq se inizializzi l'oggetto(new....) come parallelepiped, la conversione a parallelepiped* ti da accesso a tutti i dati.
Nuovo giro, nuovo gioco
Come fare a dichiarare dinamicamente degli array? Mi spiego meglio:
Nel ciclo riportato qua sopra vorrei far si che ad ogni iterazione mi venga generato un nuovo array. invece così facendo mi ripiazza sempre il puntatore alla medesima locazione di memoria quindi mi trovo 4784 valori uguali perchè in ogni cella del vector c'è sempre lo stesso puntatore a double -_-for(int i = 2; i <= CAMP; i++)
{
double add[4] = {x, y, z, 1.0};
preRot.push_back(add);
}
n.b.:
preRot è vector di double*... vector<double*> preRot;
Ho provato con un po' di sintassi java-like (lol QQ) ma niente, documentazione su internet idem.
Dai lo so che voi illuminati ci mettete 10 secondi a risolvere sta troiata, elargitemi la conoscenza![]()
Last edited by Axet; 5th November 2009 at 19:38.
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
int = 2 non da errore?
edit: visto la classe vector asd
Edito ovviamente è int i, ho scritto non ho copia-incollato![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Madooo che ditarculoooo. Scompaio di nuovo..
Ce l'ho fatta, sbagliavo a usare la new come un pollo![]()
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
Ma non lo banniamo sto qua? E' una sorta di strano bot ..
I'm no hero. Never was. Never will be.
-----
Soul of the mind, key to life's ether
Soul of the lost, withdrawn from its vessel
May strength be granted so the world might be mended...
So the world might be mended...
è un bot all'incontrario