C++ MFC

Moderators: Lundin
Number of threads: 3337
Number of posts: 9005

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
static_cast int to CString Posted by tvr on 28 Dec 2011 at 7:50 AM
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.

template<typename T>
T Get( CGraphWnd& oGraph, GR_PARAM eparam, T* )
{
int nValue;
if( !ograph.GetIntParameter( eparam, &nValue ) )
AfxThrowOleException( E_FAIL );
return static_cast<T>( 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?





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.