February 5th, 2009, 04:51 AM
Initialization of constant pointer reference member variable
I've created an application in VC++ 6.0. Pls see the code below.
i have two members. First one: m_a is a constant reference to pointer of int.
TestClass(); // standard constructor
const int *& m_a;
The next one: m_b is an int pointer.
In the constructor i've initialized the members as shown below.
Then i built it in VC++ 6.0, No errors shown, everything was fine.
Then I opened the same application in VC++ 9.0 (VS2008), It is showing a compilation error as follows.
1>d:\technical\TestClass\TestClass.cpp(66) : error C2440: 'initializing' : cannot convert from 'int *' to 'const int *&'
1> Conversion loses qualifiers
1>d:\technical\TestClass\TestClass.cpp(66) : error C2439: 'TestClass::m_a' : member could not be initialized
1> d:\technical\TestClass\TestClass.h(55) : see declaration of 'TestClass::m_a'
Why this error happens? Is there any way to solve this error? Please help....
Last edited by rageshc; February 5th, 2009 at 06:27 AM.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.