C++ cannot specify explicit initializer for arrays  [VS Community 2013 Update 4]

Posted on 2015-01-07
Last Modified: 2015-01-08
Hello, How are you?

I have this error:

Error      1      error C2536: 'Address::Address::Enemys' : cannot specify explicit initializer for arrays

class Address{
	static Address& Instance(){
		static Address addr;
		return addr;
	const DWORD Enemys[64] = { 0 };

Open in new window

I was searching in Google, and it says this is a bug.

I'm using Visual Studio Community 2013 Update 4.

What i do? I need to use singleton.

Question by:Júlio
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

Accepted Solution

jkr earned 500 total points
ID: 40537080
It is a bug, that should not happen.

>> What i do? I need to use singleton.

One simple workaround would be to

class Address{
	static Address& Instance(){
		static Address addr;

                if (!initialized) {

                   initialized = true;

		return addr;
	const DWORD Enemys[64] = { 0 };
        static bool initialized;;
bool Address::initialized = false;

Open in new window


Author Comment

ID: 40537616

Now other error:

Error      3      error C2070: 'unknown': illegal sizeof operand
7      IntelliSense: a nonstatic member reference must be relative to a specific object
Error      2      error C2597: illegal reference to non-static member 'Address::Enemys'      

i think will use a vector. This is given to many errors. Ty for your time jkr!

EDIT: yes, i just changed to vectors and it's working fine now

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question