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.Code:class TestClass{ public: TestClass(); // standard constructor const int *& m_a; int* m_b; };
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.Code:TestClass::TestClass() :m_b(0), m_a(m_b) { }
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....


Reply With Quote

Bookmarks