Diagnostic 411: entity-kind "entity" defines no constructor to initialize the following:

Submit New Article

November 15, 2008 11:00 PM PST


Cause:

The initializer list with constructor is the only way you can initialize the constant members of a class in C++."const" must already be defined before any user-written code is executed ( including the constructor) and with initializer list you can achieve this.

Code which do not define constructor for initializing const member generates this warning:

struct mystruct { 
	const int CONST;
};

 >icl /c test.cpp
Intel(R) C++ Compiler Professional for applications running on IA-32, Version 11
.0    Build 20080930 Package ID: w_cproc_p_11.0.066
Copyright (C) 1985-2008 Intel Corporation.  All rights reserved.

test.cpp
test.cpp(1): warning #411: class "mystruct" defines no constructor to initialize
 the following:
            const member "mystruct::CONST"
  struct mystruct {
         ^

Default Type: "warning"

Compiler generates a similar warning( #409 - http://software.intel.com/en-us/articles/cdiag409 ) when class having const member provides no initializer.

Resolution:

  1. Provide a constructor with initializer list that initializes the const member of the class


Do you need more help?


This article applies to: ISN General,   Intel® C++ Compiler for Linux* Knowledge Base,   Intel® C++ Compiler for Mac OS X* Knowledge Base,   Intel® C++ Compiler for Windows* Knowledge Base,   Intel® Parallel Composer Knowledge Base