Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:33:47+00:00 2026-06-17T10:33:47+00:00

I’m writing codes for a c++ assignment and I’ve got Queue.h and Queue.cpp file.

  • 0

I’m writing codes for a c++ assignment and I’ve got Queue.h and Queue.cpp file. But cannot make use of them coz when I put #include “Queue.h” in the main(). I got the above problem in the line 12 of Queue.h file.

error C2371: 'ItemType' : redefinition; different basic types

I wanted to put RecordService class as Itemtype.

My Queue.h file is below.

#pragma once
#ifndef Queue_H
#define Queue_H
#include<iostream>
#include<string>
#include "RecordService.h"
using namespace std;

typedef RecordService ItemType;  // << problem here

/** ADT queue - Pointer-based implementation. */
class Queue
{
private:
    /** A node on the queue. */ 
    struct Node
    {
        /** A data item on the queue. */
        ItemType item;
        /** Pointer to next node.     */
        Node    *next;
    }; // end Node

    /** Pointer to front node in the queue. */
    Node *frontNode;
    /** Pointer to back node in the queue. */
    Node *backNode;

public:

   /** Default constructor. */
   Queue();

   /** Destructor. */
   ~Queue();

// Queue operations:
   bool isEmpty() const;
   bool enqueue(ItemType& newItem);
   bool dequeue();
   bool dequeue(ItemType& item);
   void getFront(ItemType& item) const;

}; // end Queue
// End of header file.

#endif

My Queue.cpp is here

#include "Queue.h"  // header file


Queue::Queue(void)
{   
}  // end default constructor


Queue::~Queue()
{
   while (!isEmpty())
      dequeue();
}  // end destructor

bool Queue::isEmpty() const
{
   return backNode == NULL;
}  // end isEmpty

bool Queue::enqueue(ItemType& newItem)
{
     // create a new node
      Node *newNode = new Node;
      newNode->item = newItem;
      newNode->next = NULL;

      // insert the new node
      if (isEmpty())
     // insertion into empty queue
         frontNode = newNode;
      else
     // insertion into nonempty queue
         backNode->next = newNode;

      backNode = newNode;  // new node is at back
      return true;

}  // end enqueue

bool Queue::dequeue() 
{
   if(isEmpty())
        {
            cout<<"The queue is empty."<<endl;
        }
        else
        {
            Node *temp= frontNode;
            if(frontNode==backNode)
            {
                frontNode=NULL;
                backNode=NULL;
            }
            else
                frontNode=frontNode->next;

            temp->next=NULL;
            delete (temp);
        }
        return true;  // end if

}  // end dequeue

bool Queue::dequeue(ItemType& item)
{
   if(isEmpty())
    {
        cout<<"The queue is empty."<<endl;
    }
    else
    {
        item = frontNode->item;
        dequeue();
    }
    return true;

}  // end dequeue

void Queue::getFront(ItemType& item) const
{
   if (!isEmpty())
      // queue is not empty; retrieve front
      item = frontNode->item;
    else 
        cout << "The queue is empty." << endl;
}  // end getFront

u may see that i want to put RecordService as Itemtype in “Queue.h” header. Here is RecordService.h

#pragma once
#ifndef RecordService_H
#define RecordService_H
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

class RecordService
{
public:
    RecordService();
    RecordService(string, string, string, int, double, bool, string);
    ~RecordService();

    //set methods
    void setTransID(char);
    void setCusName(string);
    void setVehicleNo(string);
    void setCarType(string);
    void setWashDuration(int);
    void setShampooDuration(int);
    void setPolishDuration(int);
    void setVacuumDuration(int);
    void setTotalDuration(int,int,int,int);
    void setWashingCharge(double);
    void setShampooingCharge(double);
    void setPolishingCharge(double);
    void setVacuumingCharge(double);
    void setTotalCharge(double,double,double,double);
    void setRewardStatus(bool);
    void setDateOfTrans(string);

    //get methods
    char getTransID();
    string getCusName();
    string getVehicleNo();
    string getCarType();
    int getWashDuration();
    int getShampooDuration();
    int getPolishDuration();
    int getVacuumDuration();
    int getTotalDuration();
    double getWashingCharge();
    double getShampooingCharge();
    double getPolishingCharge();
    double getVacuumingCharge();
    double getTotalCharge();
    bool getRewardStatus();
    string getDateOfTrans();

private:
    char transID;
    string CusName;
    string vehicleNo;
    string carType;
    int WashDuration;
    int ShampooDuration;
    int PolishDuration;
    int VacuumDuration;
    int TotalDuration;
    double WashingCharge;
    double ShampooingCharge;
    double PolishingCharge;
    double VacuumingCharge;
    double TotalCharge;
    bool RewardStatus;
    string DateOfTrans;

};
#endif

Appreciation in advance for helping me. I cannot move on to other parts because of this error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:33:48+00:00Added an answer on June 17, 2026 at 10:33 am

    ItemType could be moved inside the Queue class. Now it may collide with other headers of yours that has ItemType defined.

    So instead of

    typedef RecordService ItemType;  // << problem here
    
    /** ADT queue - Pointer-based implementation. */
    class Queue
    {
        ...
    }
    

    use

    /** ADT queue - Pointer-based implementation. */
    class Queue
    {
        typedef RecordService ItemType;
    
        ...
    }
    

    ItemType will still be accessible as ItemType inside the Queue and Queue::ItemType outside the Queue class (if made public)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I am confused How to use looping for Json response Array in another Array.
I've got a string that has curly quotes in it. I'd like to replace
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.