Hi,
I am using VS 2005.
If I compile the following code only line 6 returns me an error while
line 9 returns a warning. If I comment the line 6 and debug the
program the assignments of lines {9, 11} work fine.
Why the '.' "scope operator" is accepted in line 9 and not in line 6?
thanks.
Marco.
//-----------
using namespace System;
int main()
{
double d;
d = Math.Cos(1.0); // line 6
d = Math::Cos(1.0);
d = Math.PI; // line 9
d = 0;
d = Math::PI; // line 11
}
------ Rebuild All started: Project: scope, Configuration: Debug Win32
------
Deleting intermediate and output files for project 'scope',
configuration 'Debug|Win32'
Compiling...
stdafx.cpp
Compiling...
scope.cpp
scope.cpp(6) : warning C4832: token '.' is illegal after UDT
'System::Math'
scope.cpp : see declaration of 'System::Math'
scope.cpp(6) : error C2275: 'System::Math' : illegal use of this type
as an expression
scope.cpp : see declaration of 'System::Math'
scope.cpp(9) : warning C4832: token '.' is illegal after UDT
'System::Math'
scope.cpp : see declaration of 'System::Math'
AssemblyInfo.cpp
Generating Code...
Build log was saved at "file://e:\Project C++ NET
2005\Prove\scope\scope\Debug\BuildLog.htm"
scope - 1 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Jacobo Rodriguez Villar - 02 Nov 2004 10:40 GMT
Because .PI is a 'structure' member and Cos is static function member
> Hi,
>
[quoted text clipped - 46 lines]
> scope - 1 error(s), 2 warning(s)
> ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Signature
Jacobo Rodríguez Villar
TyphoonLabs Lead Programmer
http://www.typhoonlabs.com
Marco Segurini - 02 Nov 2004 11:48 GMT
> Because .PI is a 'structure' member and Cos is static function member
Thanks Jacobo,
the Intellisense tells me that PI and Cos are both 'static members' of
the Math class. So like happens using a not managed c++ class only one
scope syntax has to be permitted (::).
Bye.
Marco.
Tomas Restrepo \(MVP\) - 03 Nov 2004 00:20 GMT
Marco,
> Thanks Jacobo,
>
> the Intellisense tells me that PI and Cos are both 'static members' of
> the Math class.
They are.
> So like happens using a not managed c++ class only one
> scope syntax has to be permitted (::).
Well, as it should, since they are static (and there's no instance to call
it from). The code is incorrect in that it tried to use the '.' operator to
reference Math::PI.

Signature
Tomas Restrepo
tomasr@mvps.org