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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:44:48+00:00 2026-06-12T06:44:48+00:00

I am working on a project that requires a class QueueArray that is an

  • 0

I am working on a project that requires a class QueueArray that is an Array of Queues. It’s been a while since I worked with c++ Arrays so I’m having some trouble debugging why my code is throwing errors.

I read Delete an array of queue objects for some inspiration (along with a couple hours on Google), but I am still having errors with the following code:

    #include <iostream>
    #include <deque>
    #include <queue>
    using namespace std;

    class QueueArray
    {

        queue<int> theArray[];

        QueueArray::QueueArray(int size)
        {
            queue<int> theArray[] = new queue<int>[size];
            //theArray[] = new queue<int>[size]; //this may be closer, but also giving errors

        }
    };

the errors are:

warning C4200: nonstandard extension used : zero-sized array in struct/union
1> Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array

and

error C2075: ‘theArray’ : array initialization needs curly braces

I’ve read up about the 2nd error, but I can seem to figure out what I need to do to fix it.

I need it to be a variable sized array, with the variable passed to the class, which is why I can not initialize the size of the array up top, and It must be of global scope so I can use it in other functions within the class (the classes can’t be passed the array through a parameter).

Later on, the queues will be of a user defined type, but we’re letting them be queues of ints right now, not sure if that makes a difference. I keep seeing people suggesting the use of vectors in these cases but I don’t have a choice on this one.

Any suggestions would be appreciated.

  • 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-12T06:44:49+00:00Added an answer on June 12, 2026 at 6:44 am

    using variable sized arrays is not possible in C++. to make your code working, use a pointer, i.e.

    class QueueArray
    {
        queue<int> * const theArray;
    
        QueueArray::QueueArray(int size)
        : theArray (new queue<int>[size])
        { /* ... */ }
        ~QueueArray()
        { delete[] theArray; }
    };
    

    However, in C++ you should really avoid this and use a std::vector instead, i.e.

    typedef vector<queue<int>> QueueArray;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project that requires me to define a DSL. Since
I am working on a project that requires some image processing. The front end
Currently am working on a project that requires me to create some XML for
I am working on a project that requires me to generate a java .class
I am working on a project that requires to autocomplete textbox when some data
I've been working on a project that requires communication both directions between Java and
I have a project that I'm working on that requires changing a 'BaseSortedCollection' class
I'm working on a project that requires to convert html email into text. Below
I'm working on a project that requires a fair bit of inserting/updating rows in
I'm working on a project that requires me to programmatically create MySQL users from

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.