Oct 14, 2011 at 4:57pm Oct 14, 2011 at 4:57pm UTC
Hi All,
I have the following code where Viusal Studio is returning with syntax error while with Borland C++ i can compile it.
Value=::Value1=Value1; ::Mysetting=MySetting;
Could anyone be so kind to provide any suggestion for that ?
Thanks for any help in advance.
Oct 15, 2011 at 7:32pm Oct 15, 2011 at 7:32pm UTC
What's the syntax error? Always post the error messages.
Oct 15, 2011 at 8:42pm Oct 15, 2011 at 8:42pm UTC
Here is the error message:
1>d:\vs\xy.c(159) : error C2059: syntax error : ':'
1>d:\vs\xy.c(159) : error C2143: syntax error : missing ';' before ':'
line 159 is where the line where the code above is.
sorry for not providing the error message earlier I am still new on this forum.
Last edited on Oct 15, 2011 at 8:44pm Oct 15, 2011 at 8:44pm UTC
Oct 15, 2011 at 8:46pm Oct 15, 2011 at 8:46pm UTC
Interesting. And it does look OK; strange, but OK. Any chance of the Borland compiler resolving a name differently? Maybe the MS compiler thinks you have a name there that doesn't belong. Any ambiguous name possibilties?
Oct 15, 2011 at 9:17pm Oct 15, 2011 at 9:17pm UTC
What should that statement do? I'm not a borland fan, but i could help you to "translate" it into MSVS.
Oct 16, 2011 at 5:18am Oct 16, 2011 at 5:18am UTC
That's standard C++, EssGeEich. It is assigning the value of Value1 to the variable in global scope ::Value1 and the variable Value in the first statement, and the second statment is assigning the value of MySetting to the variable in global scope ::Mysetting.
Oct 17, 2011 at 6:47am Oct 17, 2011 at 6:47am UTC
I have tried to do, but VS can not compile again.
error C2143: syntax error : missing ';' before ':' at ::Value=Value1; and at ::Mysettings=Mysettings;
what will happen if i would comment out these two lines ?
Oct 17, 2011 at 12:12pm Oct 17, 2011 at 12:12pm UTC
Have you tried using "this->Value"?
Oct 17, 2011 at 12:16pm Oct 17, 2011 at 12:16pm UTC
Well, if you are using Classes and are changing the class's members, using this->Value and this->Mysettings is right.