J
John
Hi,
I am working on a C++ project which has been developed with Visual
Studio.Net 2003. When I compile it with Visual Studio 2005, it gives hundred
of errors. Two of the strange errors are following, which repeated in many
places:
1-error C2664: 'action' : cannot convert parameter 1 from 'Foo *' to 'const
Foo *&'
2-error C2248: 'std::vector<_Ty>::_Myfirst' : cannot access protected member
declared in class 'std::vector<_Ty>'
with
[
_Ty=oid
]
------------------
Borland C++Builder compiles the same code without any error! What's wrong
with Visual Studio 2005?
Does any body know what's the problem and how to fix it? I'd appreciate any
help.
Here is a simple test program to show the error:
// -- CPPConstTest1.cpp
class Foo{
public:
Foo();
private:
int index;
};
void action(const Foo*& cptr);
int main()
{
Foo* fPtr = new Foo();
action(fPtr);
return 0;
} // end of main
//---------------------------
Foo::Foo(){
index=0;
}
//----------------
void action(const Foo*& cptr){
}
//---------------------- Build Output with Visual Studio
2005: ---------------------
------ Build started: Project: CPPTestVS05, Configuration: Debug
Win32 ------
Compiling...
CPPConstTest1.cpp
..\CPPConstTest1.cpp(17) : error C2664: 'action' : cannot convert parameter 1
from 'Foo *' to 'const Foo *&'
Conversion loses qualifiers
CPPTestVS05 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am working on a C++ project which has been developed with Visual
Studio.Net 2003. When I compile it with Visual Studio 2005, it gives hundred
of errors. Two of the strange errors are following, which repeated in many
places:
1-error C2664: 'action' : cannot convert parameter 1 from 'Foo *' to 'const
Foo *&'
2-error C2248: 'std::vector<_Ty>::_Myfirst' : cannot access protected member
declared in class 'std::vector<_Ty>'
with
[
_Ty=oid
]
------------------
Borland C++Builder compiles the same code without any error! What's wrong
with Visual Studio 2005?
Does any body know what's the problem and how to fix it? I'd appreciate any
help.
Here is a simple test program to show the error:
// -- CPPConstTest1.cpp
class Foo{
public:
Foo();
private:
int index;
};
void action(const Foo*& cptr);
int main()
{
Foo* fPtr = new Foo();
action(fPtr);
return 0;
} // end of main
//---------------------------
Foo::Foo(){
index=0;
}
//----------------
void action(const Foo*& cptr){
}
//---------------------- Build Output with Visual Studio
2005: ---------------------
------ Build started: Project: CPPTestVS05, Configuration: Debug
Win32 ------
Compiling...
CPPConstTest1.cpp
..\CPPConstTest1.cpp(17) : error C2664: 'action' : cannot convert parameter 1
from 'Foo *' to 'const Foo *&'
Conversion loses qualifiers
CPPTestVS05 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========