-
March 5th, 2006, 01:13 PM
#1
how to autogenerate array?
let say, in my program i want to create an array for matrices. user can choose any name for the matrices. so, user can create as many matrices as they want. how can i make an autogenerate array so that it won't just limit to 2 - 3 matrices only.
-
March 5th, 2006, 01:17 PM
#2
Re: how to autogenerate array?
Use a vector of matrices? Or maybe a map, if the name of a matrix is particularly significant here.
-
March 5th, 2006, 01:23 PM
#3
Re: how to autogenerate array?
can u give me some example?
-
March 5th, 2006, 01:24 PM
#4
Re: how to autogenerate array?
Originally Posted by magix24
let say, in my program i want to create an array for matrices. user can choose any name for the matrices. so, user can create as many matrices as they want. how can i make an autogenerate array so that it won't just limit to 2 - 3 matrices only.
If you want to use an array, you can only make it that big that the probability one needs to create so many matrices is very low.
Or you have to dynamically create a new bigger array everytime a new matrix is created, copy the data from the old and delete the old.
But both methods are not very good practice. You normally would use a linked list, or similar structures.
Please don't forget to rate users who helped you!
-
March 5th, 2006, 01:50 PM
#5
Re: how to autogenerate array?
can anyone teach me how to use dynamic array?
-
March 5th, 2006, 02:45 PM
#6
Re: how to autogenerate array?
you can teach yourself.
Search the web for std::vector.
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
March 5th, 2006, 09:54 PM
#7
Re: how to autogenerate array?
quoted from C++ Coding Standards:
KISS (Keep It Simple Software):
Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
Avoid magic number:
Programming isn't magic, so don't incant it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|