![]() |
|
#1
|
|||
|
|||
Dynamic ArraysOk back to the questions
I've created a database of CD's in which the Database class is simply an array of pointers to CD's (another class). I've initialized it as such: Code:
Now my question is how I can replace that 50 with a number that can change. For instance, make an array the size of the CD's in the database. Because once I have 50 CD's in the Database it will simply just start writing over them. Anyone got any ideas? |
|
#2
|
||||
|
||||
|
CPP / C++ / C Code:
this way you can create an array of size detrmined during runtime, but be careful if you need to change the size, delete it first then create a new one with the same size. __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
||||
|
||||
|
Quote:
You could also use the STL containers - like std::vector. It is resizable, while the c++ array lacks this capability. Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem reading to a dynamic array | noamfrie | C Programming Language | 9 | 02-Jan-2005 18:35 |
| Knight tour (arrays help needed) | dilmv | C++ Forum | 7 | 18-Oct-2004 14:31 |
| problems with 2d arrays.. | mgdpetter | C Programming Language | 12 | 27-May-2004 20:45 |
| need help with passing 3 arrays into a function | tommy69 | C Programming Language | 14 | 07-Apr-2004 00:22 |
| Problem multiplying arrays | hellhammer | C Programming Language | 9 | 29-Mar-2004 15:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The