title: C++ How can I initialize array of structs to null and later check if an element of this array is null in a while loop?
body: <p>I'm trying to write a queue implementation using a circular array in C++. I got that part right but my assignment asks me to print the Queue in a function in main.cpp. This poses a problem for me because I will have to print it in a while loop and the size of the queue is not necessarily it's max size at compile time.</p>
  
  <p>For example: if the user enqueues 2 passengers in a queue that has max size 3, and I want to print the passengers in the queue, I'll have to let the while loop go on for only 2 iterations. But I am not allowed to pass the size of the queue so the only way I can do this is check if the passenger structs in the queue are not NULL. I don't know what NULL means within the context of structs. </p>
  
  <p>This is my header file CQueue.h.</p>
  
  <pre><code>const int MAX = 3;
  
  struct Passenger {
      char name[80];
  };
  
  class CQueue {
  private:
      int front;
      int rear;
      Passenger passengers[MAX];
  
  public:
      CQueue();
      bool IsEmpty();
      bool IsFull();
      void Enqueue(Passenger);
      Passenger Front(); // Returns the passenger type at the front index of array
      void Dequeue();
  };
  </code></pre>
  
  <p>This is my class constructor in CQueue.cpp</p>
  
  <pre><code>CQueue::CQueue() // Custom constructor initializes the fields of the CQueue class with the appropriate values
  {
      front = -1; // Conditions for emptiness of CQueue
      rear = -1; // Conditions for emptiness of CQueue
      ??? // needs a line to initialize passengers[MAX] elements to some default NULL value
  }
  </code></pre>
  
  <p>And this is what I'm trying to do in my main.cpp. I'm trying to print the Queue elements in order, but only the ones that have been inputted by the user. In other words, I don't want to print the empty elements.</p>
  
  <pre><code>while (???) // check if passanger is not the default null value
      {
          cout &lt;&lt; CQueue.Front() &lt;&lt; "\n";
          copyQueue.Dequeue();
      }
  </code></pre>
  
  <p>I'm uncertain what I should put in the place of ???. I've tried a bunch of different methods but it boils down to the simple fact that I don't know what a NULL value for a struct is. </p>
  
  <p>Thanks in advance!</p>