There must be a better way
Derek Parnell
derek at nomail.afraid.org
Tue Aug 1 21:43:53 PDT 2006
On Wed, 2 Aug 2006 05:49:44 +0200, Emp wrote:
> About the inout:
> How would you do something like this?
>
> bool something(inout structure struc ,int var){
> for (int i=0; i < struc.data[].length; i++){
> if(struc.data[i].count==0){
> struc.data[i].type=var;
> struc.data[i].count=30;
> return true;
> }
> }
> return false;
> }
Ah yes... the problem with structs. The way you have done it here is a
trade-off for performance and works fine. The alternative would be to pass
back and forth the complete structure which is not a generally a good idea.
You could make it a class instead of a structure but that would be just
pedantic ;-)
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
2/08/2006 2:39:58 PM
More information about the Digitalmars-d-learn
mailing list