|
From: Louis G. <lg...@ya...> - 2003-02-22 20:42:04
|
Ioannis:
the original question was:
RB>Saturday, February 22, 2003, Robson wrote as follows:
RB> Hi! I'm in trouble again! My c++ book does not explain how to redim
an array at run time, preserving contents.
RB> I want to resize an array of sprites every time that user presses
'N' key,
...How does the program below adjust array size at run-time ?
--- Ioannis Vranos <no...@ho...> wrote:
> -------Original Message-------
>
> From: Robson Bernard
> Date: ÓÜââáôï, 22 ÖåâñïõÜñéïò 2003 7:04:19 ìì
> To: C++ Mail List
> Subject: Re: [Dev-C++] Resize Arrays
>
>
> Could you make a simple demo with a vector of ints so i can understand
> it better?
>
> #include <iostream>
> #include <vector>
>
> int main()
> {
> using namespace std;
>
> // An array of 20 integers with initial default value 0
> vector<int> myiarray(20);
>
> // Initial value 1
> vector<double>mydarray(20,1);
>
> myiarray.push_back(7);
>
> // vector::size_type is a typedef of an unsigned integer type.
> // One could use unsigned long in its place for example
> for(vector<int>::size_type i=0; i<myiarray.size(); ++i)
> cout<<myiarray[i]<<endl;
>
> }
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
|