C2440 Compiler Error

I am getting error c2440 in my compiler, but I cannot figure out what causes it.

This is mistake:

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 corresponding code:

 String *strFilename = 0; 
+4
source share
3 answers

The managed types used in managed C ++ do not use stars (i.e. *), instead, I think they are called tracking descriptors (i.e. ^). Thus, your expression should be written as follows:

 String^ strFilename = nullptr; 
+4
source
 String *strFilename = "0"; 

not

 String *strFilename = 0; 
+2
source

System :: String is a managed class. I suppose you should use the nullptr keyword to initialize it.

+2
source

All Articles