Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Airplane Pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 43748 of 48417
Post > Topic >>

Re: Airplane Program with Linked Lists. The linked list ****tion is very confusing to me.

by "Chris Thomasson" <cristom@[EMAIL PROTECTED] > Mar 9, 2008 at 08:38 PM

"Chris Thomasson" <cristom@[EMAIL PROTECTED]
> wrote in message 
news:DsadnZfGosSMfEzanZ2dnUVZ_gCdnZ2d@[EMAIL PROTECTED]
>
> "jawdoc" <drbrooks@[EMAIL PROTECTED]
> wrote in message 
>
news:e66bcfe8-d62d-442f-b333-2ac4eb1b737a@[EMAIL PROTECTED]
> [...]
>
>> I just need some direction for using the linked lists instead
>> of the 2 dimensional arrays. Both versions are provided. Any help is
>> greatly appretiated.
>
> This should help get you started:
> ___________________________________________________________
> class airplane {
[...]
>
>  struct row {
>    row* next;
>    seat* seats;
>  };

[...]

>  seat* find_seat(int row, int col) const {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

WHOOPS! Humm, I think I should rename the row variable in
'airplane::find_seat()'!
___________________________________________________________
class airplane {
  struct seat {
    seat* next;
    // [...]
  };

  struct row {
    row* next;
    seat* seats;
  };


  row* m_rows;


  seat* find_seat(
   std::size_t idx_row,
   std::size_t idx_col
  ) const {
    row* r = m_rows;
    while (r && idx_row > 1) {
      idx_row--;
      r = r->next;
    }
    if (r && idx_row == 1) {
      seat* s = r->seats;
      while (s && idx_col > 1) {
        idx_col--;
        s = s->next;
      }
      if (s && idx_col == 1) {
        return s;
      }
    }
    return NULL;
  }


public:
  // [...]
};

___________________________________________________________


Sorry about that non-sense. ;^)
 




 10 Posts in Topic:
Airplane Program with Linked Lists. The linked list portion is v
jawdoc <drbrooks@[EMAI  2008-03-07 12:33:08 
Re: Airplane Program with Linked Lists. The linked list portion
Christopher <cpisz@[EM  2008-03-07 13:36:47 
Re: Airplane Program with Linked Lists. The linked list portion
jawdoc <drbrooks@[EMAI  2008-03-07 14:44:12 
Re: Airplane Program with Linked Lists. The linked list portion
Christopher <cpisz@[EM  2008-03-07 15:20:05 
Re: Airplane Program with Linked Lists. The linked list portion
"Christopher Pisz&qu  2008-03-07 17:52:44 
Re: Airplane Program with Linked Lists. The linked list portion
Christopher <cpisz@[EM  2008-03-07 15:32:40 
Re: Airplane Program with Linked Lists. The linked list portion
"Chris Thomasson&quo  2008-03-07 16:42:32 
Re: Airplane Program with Linked Lists. The linked list portion
"Chris Thomasson&quo  2008-03-09 20:38:51 
Re: Airplane Program with Linked Lists. The linked list portion
jawdoc <drbrooks@[EMAI  2008-03-07 18:04:12 
Re: Airplane Program with Linked Lists. The linked list portion
"Daniel T." <  2008-03-07 21:57:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 10:01:45 CST 2008.