If you will set a corresponding compiler option to clr:oldsyntax
in the project properties as the first message says, then the following code compiles without errors in Visual Studio 2010:
#include "stdafx.h"
using namespace System;
__gc class A
{
public:
A( String *s ) : data( s ) {}
String * get_data() { return data; }
private:
String *data;
};
int main()
{
A *pa = new A( "Hello World" );
Console::WriteLine( pa->get_data() );
return 0;
}
It seems that the second message is the result of that you did not set the option pointed out in the first message.
You should select menu Project → Properties → General → *Supporting of CLR (or something else because I have the Russian release of Visual Studio 2010 I can not name the option exactly in English) → clr:oldsyntax