static_cast int to CString - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

static_cast int to CString

tvrtvr Posts: 1Member
I am converting some old VC-6 MFC code to VC-10 (64 bit) that was done by a previous employee and have a problem. There is a template defined that uses a static_cast to convert an int to a CString. The VC-6 compiler had no problem with it but the VC-10 compliler complains.

T Get( CGraphWnd& oGraph, GR_PARAM eparam, T* )
int nValue;
if( !ograph.GetIntParameter( eparam, &nValue ) )
AfxThrowOleException( E_FAIL );
return static_cast( nValue );
CString Get( GraphWnd& ograph, GR_PARAM eparam, CString* );

The error is: "Error C2440: static_cast cannot convert from int to CString."

I am suspecting there is a compiler option that needs to be done (or undone) but cannot find anything. Any ideas?


Sign In or Register to comment.