title: How can I enqueue a structure object into a queue when both are templates?
body: <p>I am trying to push a structure object into a linked list or array queue. I'm using this data structure to meet the following condition:</p>
  <p>&quot;Customer history: this function adds customers to your data structure. If
  the data structure is full, it will delete the very old customer&quot;</p>
  <p>The struct holds three variables, the customer's name, email and phone number, and they will all be of the string data type. A requirement of the project is that all functions, classes, and data structures have to be a template, and I am having trouble enqueuing the struct into the queue. I'll supply the code I have below:</p>
  <p>This is my struct:</p>
  <pre><code>
  template &lt;class T&gt;
  struct Customer {
      T Cname; //Customer Name
      T Cemail;  //Customer E-mail
      T Cphnum; //Customer Phone
  
      Customer&lt;T&gt; (T n, T e, T phn) {
         Cname=n; 
         Cemail=e;
         Cphnum=phn;
      }
  
      T get_name() {
          return Cname;
          cout &lt;&lt; Cname;
      }
  
      T get_email() {
          return Cemail;
      }
  
      T get_phnum() {
          return Cphnum;
      }
  } ;
  
  </code></pre>
  <p>This is the function to input the information into the struct and then into the queue:</p>
  <pre><code>template &lt;class T&gt;
  void input_customer_info(T n, T e, T phn) {
  
      //Customer Information
      T Cn = n;   //Customer Name
      T Ce = e;  //Customer E-mail
      T Cph = phn;  //Customer Phone Number
  
      Customer&lt;string&gt; c(Cn ,Ce ,Cph);
      
  
      Queue&lt;string&gt; CI;
      CI.enQueue(c);
  }
  </code></pre>
  <p>And this is my main function:</p>
  <pre><code>int main(){
      int input = 0;
      while (input != 1) {
          //User Input of Information 
          string nm, em, ph;
          cout &lt;&lt; &quot;Please Enter Your Name: &quot; &lt;&lt; endl;
          cin &gt;&gt; nm;
          cout &lt;&lt; &quot;Please Enter Your Email Address: &quot; &lt;&lt; endl;
          cin &gt;&gt; em;
          cout &lt;&lt; &quot;Please Enter Your Phone Number: &quot; &lt;&lt; endl;
          cin &gt;&gt; ph;
          
          //Function to input the Customer's info into a queue
          input_customer_info(nm, em, ph);
  
          cout &lt;&lt; &quot;Enter 1 or 0: \n1 to stop entering  Customer Info, \n0 to enter more Customer Info&quot; &lt;&lt; endl;
          cin &gt;&gt; input;
      }
  
  }
  </code></pre>
  <p>This is the Linked List Queue implementation I am first testing with, but I might go with the array implementation because it allows me to set a limit to the queue:</p>
  <pre><code>template &lt;typename T&gt;
  struct QNode {
      T data;
      QNode* next;
      int count;
      QNode(T d)
      {
          count = 0;
          data = d;
          next = NULL;
      }
  };
  
  template &lt;typename T&gt;
  struct Queue {
      QNode&lt;T&gt;* front, * rear;
      Queue()
      {
          front = rear = NULL;
      }
  
      void enQueue(T x)
      {
  
          // Create a new Linked-List node
          QNode&lt;T&gt;* temp = new QNode&lt;T&gt;(x);
  
          // If queue is empty, then
          // new node is front and rear both
          if (rear == NULL) {
              front = rear = temp;
              return;
          }
  
          // Add the new node at
          // the end of queue and change rear
          rear-&gt;next = temp;
          rear = temp;
      }
  
      // Function to remove
      // a key from given queue q
      void deQueue()
      {
          // If queue is empty, return NULL.
          if (front == NULL)
              return;
  
          // Store previous front and
          // move front one node ahead
          QNode&lt;T&gt;* temp = front;
          front = front-&gt;next;
  
          // If front becomes NULL, then
          // change rear also as NULL
          if (front == NULL)
              rear = NULL;
  
          delete (temp);
      }
  };
  </code></pre>
  <p>Array Queue Implementation:</p>
  <pre><code>template &lt;class T&gt;
  struct AQueue {
      int front, rear;
      int capacity;
      int* queue;
  
      
      AQueue (int c) {
          front = rear = 0;
          capacity = c;
          queue = new int;
      }
  
      ~AQueue() { delete[] queue; }
  
      void enqueue(T data) {
          if (capacity == rear) {
              cout &lt;&lt; &quot;Queue is full\n&quot;;
              return;
          }
          else {
              queue[rear] = data;
              rear++;
          }
          return;
      }
  
      void dequeue() {
          if (front == rear) {
              cout &lt;&lt; &quot;Queue is empty\n&quot;;
              return;
          }
          else {
              for (int i = 0; i &lt; rear - 1; i++) {
                  queue[i] = queue[i + 1];
              }
              rear--;
          }
          return;
      }
  };
  </code></pre>
  <p>Where I'm having trouble is at the &quot;input_customer_info&quot; function where I'm trying to enqueue the struct object &quot;c&quot; into the linked list queue &quot;CI&quot;. I'm getting the following error in the image below:</p>
  <p><a href="https://i.stack.imgur.com/EgET6.png" rel="nofollow noreferrer">Image of error C2664 description</a></p>
  <p>I don't really know how to fix it, so if I can get some help that would be great. Thanks.</p>