how to declare a one based array ?
-
timbk wrote:
hello, is there any way to declare an indexed array in base one on VC++? thanks.
You can even use ten-based array: just remember to subract
10
to the index before using it inside the[]
operator... :rolleyes: [added] Hi, Mr.Univoter. Don't you like10
-based arrays, do you? :-D [/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Wednesday, November 11, 2009 3:04 AM
-
As they said, no, but you could write your own 1 based array class in C++ and overload the [] operator and whatever else is necessary to do the index adjustment for you. X|
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
-
timbk wrote:
hello, is there any way to declare an indexed array in base one on VC++? thanks.
You can even use ten-based array: just remember to subract
10
to the index before using it inside the[]
operator... :rolleyes: [added] Hi, Mr.Univoter. Don't you like10
-based arrays, do you? :-D [/added]If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Wednesday, November 11, 2009 3:04 AM
-
timbk wrote:
thanks, how can i do to declare a ten based array?
Do you understand irony music, Yoko? :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
As they said, no, but you could write your own 1 based array class in C++ and overload the [] operator and whatever else is necessary to do the index adjustment for you. X|
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
thanks, well i was trying to make the app more easy to follow, because 0 based arrays are not so intuitive, we starts count in one, i think that the easy way is make the array one element bigger but when you have many arrays is a waste of memo, so i would try with your seggest.
-
timbk wrote:
thanks, how can i do to declare a ten based array?
Do you understand irony music, Yoko? :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
thanks, well i was trying to make the app more easy to follow, because 0 based arrays are not so intuitive, we starts count in one, i think that the easy way is make the array one element bigger but when you have many arrays is a waste of memo, so i would try with your seggest.
-
I'm sorry for you.
C/C++
arrays are zero based. While there's nothing wrong in liking better one-based arrays, it is wiser remaining stuck with zero-based ones, because:- You need extra work to make your arrays alive (extra work is generally bad)
- Most people use the opposite convention: that means you have to adapt your data to any time you've to deal with other people code, like libraries, etc..
Neverthless, there are few examples of consistently used one-based arrays, for instance, all "Numerical Recipes" book source code uses it (the authors simply ignore array item
0
). Like all 'alien' conventions it's a bit difficult to grasp immediately, but after some experience with, becomes 'natural'. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
thanks, well i was trying to make the app more easy to follow, because 0 based arrays are not so intuitive, we starts count in one, i think that the easy way is make the array one element bigger but when you have many arrays is a waste of memo, so i would try with your seggest.
timbk wrote:
i was trying to make the app more easy to follow, because 0 based arrays are not so intuitive
you will confuse any C/C++ programmer who has to maintain the code, if you start doing things like that.
-
timbk wrote:
i was trying to make the app more easy to follow, because 0 based arrays are not so intuitive
you will confuse any C/C++ programmer who has to maintain the code, if you start doing things like that.