Author Topic: ResbufList class  (Read 11246 times)

0 Members and 1 Guest are viewing this topic.

pkohut

  • Bull Frog
  • Posts: 427
Re: ResbufList class
« Reply #30 on: March 25, 2011, 12:48:09 AM »
Good code,but I don't know how to use.

See this post for ResbufList in use.
http://www.theswamp.org/index.php?topic=28286.0

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: ResbufList class
« Reply #31 on: March 25, 2011, 06:57:54 PM »
Thanks Paul!

On your second entry, will that even compile? I always thought those args in the for loop had to be of the same type.  :mrgreen:

Dan

pkohut

  • Bull Frog
  • Posts: 427
Re: ResbufList class
« Reply #32 on: March 25, 2011, 07:06:40 PM »
You're right. The declaration of nItems should be outside, however the assignment will still work inside.

Code: [Select]
size_t nItems = 0;
for(resbuf *pRbTemp = mpHead ; pRbTemp != NULL ; pRbTemp = pRbTemp->rbnext, ++nItems)
{
    if(idx == nItems)
        return pRbTemp;
}

... do lots of work

for(nItems =0, resbuf *pRbTemp = mpHead ; pRbTemp != NULL ; pRbTemp = pRbTemp->rbnext, ++nItems)
{
    if(idx == nItems)
        return pRbTemp;
}