Vc.net2003 to Vc.net2005 confuses

Hello everyone

I've just installed vc++ 2005 Express Edition,with the new interface I wrote a very simple test code to know exactly how it works,I have learned some .net programing in vc 2003,but find it can't build the test paper,error tip show:"use of this keyword requires /clr:oldSyntax command line option".what's the new sytax of vc2005 I also installed the msdn,where can I get help,where can I get all the new features of vc2005,eagly looking forward your help.thanks

the followwing are my test code and error tips:

#include "stdafx.h"
#using < mscorlib.dll >

__gc class Point
{
private:
double x;
double y;
public:
Point(double xx,double yy)
{
x=xx;
y=yy;
}

~Point() {}

__property void set_X(double xx)
{
x=xx;
}

__property void set_Y(double yy)
{
y=yy;
}

__property double get_X()
{
return x;
}

__property double get_Y()
{
return y;
}

void setPoint(float xx,float yy)
{
x=xx;
y=yy;
}

void setX(double xx)
{
x=xx;
}

void setY(double yy)
{
y=yy;
}

double getX()
{
return x;
}

double getY()
{
return y;
}
};

int main(array<System::String ^> ^args)
{
Point p1=gcnew Point(5.5,9.8);
Console::WriteLine(L"p1:x={0},y={1}",p1.getX().ToString(),p1.getY().ToString);
return 0;
}

1>.\PropertyTest.cpp(6) : error C4980: '__gc' : use of this keyword requires /clr:oldSyntax command line option
1>.\PropertyTest.cpp(20) : error C4980: '__property' : use of this keyword requires /clr:oldSyntax command line option
1>.\PropertyTest.cpp(69) : error C3673: 'Point' : class does not have a copy-constructor
1>.\PropertyTest.cpp(70) : error C2653: 'Console' : is not a class or namespace name
1>.\PropertyTest.cpp(70) : error C3867: 'System::Double::ToString': function call missing argument list; use '&System::Double::ToString' to create a pointer to member
1>.\PropertyTest.cpp(70) : error C3861: 'WriteLine': identifier not found




Answer this question

Vc.net2003 to Vc.net2005 confuses

  • Dan Lukinykh

    To change the syntax use this - I only have english UI texts:

    Open your project with MC++ code. Menu: Project->[your project] properties : Configuration Properties->General : Common Language Runtime support : from the combobox choose "Common Language Runtime support (/clr:oldSyntax)"

    Explaining MC++ and C++/CLI is a bit beyond a short post here. Please go on searching the web for information or buy a book.

    --
    SvenC


  • mikecuth

    OK!I can compile the test code now.Thank you 100 times :)

  • Polity4h

    Yes, you can choose /clr:oldSyntax from the project settings. Now you can compile with MC++ syntax.

    Native C++ should be quite compatible.I think the default scope of for variables changed to standard compliance - for(int i = 0; ;) { /* i is only visible in this block not beyond */ } But that change could also have been introduced with VC2003. Maybe some other minor changes to get standard compliant.

    --
    SvenC


  • ConfigSSIS

    Thank you very much! By the way,can I compile a vc2003 based program in vc 2005 if it can which project should I choose when build a new project It's import for me beacause All of my other classmates and my teacher are using vc2003.

  • Jkumar

    Thank you again for your help,but still I can't find the the "/clr:oldSyntax from the project settings" you told me to set,could you show me more details about the setting

    I have read the contents in "/http://msdn.microsoft.com/msdnmag/issues/06/00/PureC/default.aspx",I am from china and my English is not very well,After reading the whole article roughly still I can't slove the compile error occured from my test code(Maybe I haven't apprehended the whole article) I really want to learn more about both new&old sytax.could you give me more imformation and suggestion.

    I hope my questions won't touble you too much.Thank you again :).



  • OldDrongo

    VC++ 2005 uses a new C++/CLI syntax replacing MC++. Have a look here: http://msdn.microsoft.com/msdnmag/issues/06/00/PureC/default.aspx

    --
    SvenC


  • Vc.net2003 to Vc.net2005 confuses