Skip to main content
gamedev.net
🔒 Locked

vector problem

Started by 31337noob Jan 25, 2006 at 2:17 AM 5 replies 650+ views
Original Post
31337noob
31337noob
ok, i never seen this problem before. i have a vector called coord. its in a class called Board i have anther class called TheGameOfLife and it uses board for the points. when i click on an empty space it gets the right x,y coord and it puts it in the vector coord. after it finishes with the function addPoint in the Board class, the vector goes back to 0x000000000 for all the elements. it stores it then deletes it why?????????? how can i fix that????? please help. thanks.
MTclip
MTclip

lets see Im going to take a guess here.. (some code from you would help)


at first i thought vector was a std::vector, but after reading it again i think i maybe a math type vector.. but then you talk about the vector having elements.. so im not sure..

you probably have something like this..

void addPoint(vector vec)
{
}

when it should be this..

void addPoint(vector & vec)
{
}
31337noob
31337noob
Quote:
Original post by MTclip

lets see Im going to take a guess here.. (some code from you would help)


at first i thought vector was a std::vector, but after reading it again i think i maybe a math type vector.. but then you talk about the vector having elements.. so im not sure..

you probably have something like this..

void addPoint(vector vec)
{
}

when it should be this..

void addPoint(vector & vec)
{
}



no. its std::vector. and instead of calling the class Board board in private in the class TheGameOfLife. i did class TheGameOfLife : public Board. and that causes no problems.
MTclip
MTclip
post some code..
MTclip
MTclip
DOUBLE POST

[Edited by - MTclip on January 25, 2006 4:36:43 AM]
JonatanHedborg
JonatanHedborg
*sigh* why did they name it (stl) Vector? Talk about confusing name :D

And post some code. This is impossible to answer without something to analyze.
================<FONT COLOR="#850000
sgaffga
sgaffga
Hi!

Maybe you use std::vector for a Class that does not have an
assignment operator or a copy constructor?

Stefan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.