Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler error C2440

I am getting error c2440 in my compiler but I cannot figure out what is causing it.

This is the error:

Error 2 error C2440: 'initializing' : cannot convert from 'int' to 'System::String ^'   c:\users\***.****\documents\visual studio 2005\projects\cpas1\cpas1\Form1.h 1083

and this is the relevant code:

String *strFilename = 0;
like image 518
bigbaz34 Avatar asked Feb 22 '23 13:02

bigbaz34


1 Answers

Managed types, when used in Managed C++, don't use stars (i.e. *), instead I believe they are called tracking handles (i.e. ^). As such your statement should be written like this:

String^ strFilename = nullptr;
like image 139
C Johnson Avatar answered Mar 09 '23 06:03

C Johnson