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 6743671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:59:22+00:00 2026-05-26T11:59:22+00:00

This code works if the 7th line down says typedef char ItemType but instead

  • 0

This code works if the 7th line down says “typedef char ItemType” but instead I made it typedef to the EventInfo object. The MSVS compiler says some really weird things…

error C2146: syntax error : missing ';' before identifier 'ItemType'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

But I don’t understand why it works correctly when it is a char.

I know this is a lot of code but the typedef is on the 7th line. I included the whole thing because I don’t know what to expect.

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;

const int MaxQueueSize = 8; // Queue Struct can hold up to 8
typedef EventInfo ItemType; // the queue's data type !DOES NOT COMPILE

enum EventType {Arrival, Depart};
class EventInfo
{
public:
    EventInfo() : eTime(0), aTime(0), minutes(0) {}
    int eventTime();
    int duration();
    void ScheduleEvent(int eTime, int duration);
    bool compare(int eTime);
private:
    int eTime; //either the arrival time of the next customer or the departure time of the customer currently at the teller window
    int aTime; //either the service time for the arriving customer or the wait time for the customer at the teller window
    float minutes;
};
int EventInfo::eventTime()
{
    return this->eTime;
}
int EventInfo::duration()
{
    return this->aTime;
}
void EventInfo::ScheduleEvent(int eTime, int duration)
{
    this->eTime = eTime;
    this->aTime = duration;
}
bool EventInfo::compare(int eTime)
{
    return (eTime == this->eTime);
}

///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////
////////////////

class CPPQueue
{
public:
    CPPQueue() : front(0), rear(0), count(0) { };
    ItemType item[MaxQueueSize];
    bool IsEmpty() const;
    bool IsFull() const;
    void Enqueue(ItemType newItem);
    void PrintQ();
    void PrintQueueInfo();
    ItemType Dequeue();
    int Count();
private:
    int front, rear;
    int count;
};
bool CPPQueue::IsEmpty() const 
{
    return (this->count == 0);
}
bool CPPQueue::IsFull() const 
{
    return (this->count == MaxQueueSize);
}
void CPPQueue::Enqueue(ItemType newItem)
{
    if(this->count == MaxQueueSize)
    {
        cerr << "Error! Queue is full, cannot enqueue item.\n" << endl;
        exit(1);
    }
    this->item[this->rear] = newItem;
    this->rear++;
    if (this->rear == MaxQueueSize)
    {
        this->rear = 0; // adjustment for circular queue
    }
    this->count++;
}
ItemType CPPQueue::Dequeue()
{
    ItemType theItem;
    if(this->count == 0)
    {
        cerr << "Error! Queue is empty, cannot dequeue item.\n" << endl;
        exit(1);
    }
    theItem = this->item[this->front ];
    this->front++;
    if (this->front == MaxQueueSize)
    {
        this->front = 0; // adjustment for circular queue
    }
    this->count--;
    return theItem;
}
// Function PrintQ() prints the contents of the queue without changing
// the queue. Printing starts at the "front" index and stops before we
// get to the "rear" index. A decrementing counter controls the loop.
//
void CPPQueue::PrintQ()
{
    int i;
    int qindex = this->front;
    for(i = this->count; i > 0; i--)
    {
        cout << this->item[qindex] ;
        qindex = (++qindex) % MaxQueueSize; // adjustment for circular queue
        if(i > 1)
            cout << ", ";
    }
}
// Helper function for the main program below.
void CPPQueue::PrintQueueInfo()
{
    cout << "The queue contains: ";
    PrintQ();
    cout << endl;
}
int CPPQueue::Count()
{   
    return this->count;
}


enum TellerStatus {Idle, Busy};
class Teller
{
public:
    Teller() : status(Idle), idleTime(0), totalIdleTime(0) {}
    void changeStatus(TellerStatus status);
    TellerStatus getStatus(void);
private:
    TellerStatus status;
    int idleTime; //!
    int totalIdleTime; //!!
};
void Teller::changeStatus(TellerStatus status)
{
    this->status = status;
}
TellerStatus Teller::getStatus()
{
    return this->status;
}

class Bank
{
public:
    Bank() : Clock(0.0) {}
    void RunSimulation();
private:
    EventInfo Event[2]; // array of two events - next arrival and next departure
    CPPQueue WaitLine; // the customer wait line [with max size = 8]
    float Clock; // to keep track of Current Bank Time
    Teller theTeller; // the single teller in the bank
    ifstream myfile;
    void ProcessArrival(), ProcessDeparture(), PrintHeader(), PrintReportLine(), PrintStatsReport();
};
void Bank::RunSimulation()
{

}
void Bank::ProcessArrival()
{
    int a, b;
    string filename, x;
    filename = "P3Data1.txt";
    myfile.open(filename);
    while (myfile >> a >> b)
    {
        Event[1].ScheduleEvent(a, b);
        WaitLine.Enqueue(Event);
    }
}

int main()
{
    Bank myBank;
    myBank.RunSimulation();

}
  • 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-05-26T11:59:22+00:00Added an answer on May 26, 2026 at 11:59 am

    The name EventInfo is only usable from its point of declaration forward. Your typedef is too early, and the compiler doesn’t yet know what a EventInfo is.

    You can move the typedef below the class definition, or you can tell the compiler that EventInfo is a class:

    typedef class EventInfo ItemType;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works, but i dont understand why. With DeferredLoadingEnabld = false, I would
This code works in a windows forms application (it shows the preview) but not
This code works well in Mac/Linux, but not in Windows. import mmap import os
This code works is FF and IE but not in Chrome. Any help would
This code works in Chrome and Firefox, but not IE (which is to be
This code works, but is inefficient because it double-lookups the ignored dictionary. How can
This code works in a WPF app but throws a NetworkException (server not found)
This code works fine to send one parameter to a javascript function, but when
This code works in FF but not in IE . Im stumped why the
This code works in WPF but not in Silverlight. Are there any workarounds in

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.