Your "C++" code has nothing to do with Visual C++, nor is it a native C++ code.
You'd better ask your question in some of the .Net or in Managed C++/CLI forums