Hi, I am making a paint program with a undo button. To do that, I need the computer to remeber the lines the user has drawn and the user might have drawn a lot so I need to make an array with "infinate" elements. Can someone please give me a small example of an array with "infinate" elements?
Here are not infinite arrays. Because your computer does not have unlimited memory. But you can make new array with more space and copy one array to another. If you use all space off new array, make new and bigger array and copy all info from another array.
Or use STL containers http://www.cplusplus.com/reference/stl/
I know there are not arrays with infinate memory. I just want to define a array with the number of elements depending on what happens when the program is run.
Also if I want to do that, I need to do the things you said, can you explain them beecause I have only done C++ for a year and I am 13
I recommend that you read this: http://stackoverflow.com/questions/2746076/how-do-i-create-undo-in-c
Also, I would create a pre-allocated buffer of type either int (word size) or unsigned char (byte size). This would allow any type to be placed within the buffer. Of course, this requires the use of placement new[1]. The problem with the STL containers is that they only allow 1 specific type to be placed within it, and only allow access to 1 element at a time.