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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:28:05+00:00 2026-05-25T00:28:05+00:00

The following 3 code blocks are the main.cpp, static_class_array.cpp, and static_class_array.h respectively. I’m getting

  • 0

The following 3 code blocks are the main.cpp, static_class_array.cpp, and static_class_array.h respectively. I’m getting the following error:

static_class_array.cpp||In constructor 'static_array_class::static_array_class()':|
static_class_array.cpp|5|error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment|
||=== Build finished: 1 errors, 0 warnings ===|

#include "static_class_array.h"

int main()
{
    static_array_class* array_class;

    array_class = new static_array_class();

    delete array_class;

    return 0;
}


#include "static_class_array.h"

static_array_class::static_array_class()
{
    static_array_class::array[3] = {0,1,2};
}
static_array_class::~static_array_class(){}



#ifndef STATIC_CLASS_ARRAY_H
#define STATIC_CLASS_ARRAY_H

class static_array_class
{
    private:

        static int array[3];

    public:

    static_array_class();
    ~static_array_class();
};
#endif
  • 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-25T00:28:06+00:00Added an answer on May 25, 2026 at 12:28 am

    I think that what you want in the implementation file is:

        static_array_class::static_array_class()
        {
        }
        static_array_class::~static_array_class(){}
    
        int static_array_class::array[3] = {0,1,2};
    

    Explanation of error message

    “cannot convert ‘brace-enclosed initializer list’ to ‘int’ in
    assignment”

    in submitted code.

    This is because the code:

    static_array_class::array[3] = {0,1,2};
    

    is interpreted as meaning that {0,1,2} should be assigned to element 3 in the array. Element 3 is of type int, (and incidentally not allocated being the fourth element), so this is like:

    int i = 0;
    i = {0,1,2};
    

    Hence the error message.

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

Sidebar

Related Questions

I'm using Code::Blocks to build my project, which contains three files: main.cpp , TimeSeries.cpp
I get this solitary error while trying to compile the following code in code::blocks.
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have several blocks of the following code that each use there own matrix.
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
Given the following code... class Program { static void Main(string[] args) { Foo foo
Following code will compile but crash at run time: int main() { try {
I have the following code: <a href=main.html class=admin><div class=buttonlabel>Admin</div></a> and CSS a.admin { display:block;
I am getting a "Bus error" when I try to run this code compiled
I'm trying to build the following block of code in a 1-file .cpp file:

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.