   why do this compile
  One of my classes has public constants, and normally I would access them via the scope resolution operator, right?class Foo{public:   static const int Constant1 = 1;};int bar = Foo::Constant1;but this works also, in VC6:int bar = Foo.Constant1;does this adhere to the standard, or is it one of those VC6 anomalies?edit:it doesn't work with static member functions. so weird.[edited by - alnite on February 18, 2004 10:46:38 PM]
  For all instances of Foo, there can only be one copy of Constant1. I guess, if it''s not standard, then MS just decided that since there''s only one instance of Constant1, it wouldn''t hurt to let you access it with Foo.Constant1. ;  Woah, are you creating a Foo anywhere?  Because the .   operator shouldn''t work on a class, only on an object.  Try Foo->Constant  . ;quote:Original post by PlayGGY  Woah, are you creating a Foo anywhere?  Because the .operator shouldn''t work on a class, only on an object.  Try Foo->Constant    .   It shouldn''t. It still works whether or not there is a Foo instance. Foo->Constant doesn''t work. ;quote:Original post by PlayGGY  Woah, are you creating a Foo anywhere?  Because the .operator shouldn''t work on a class, only on an object.  Try Foo->Constant    .   ...the -> operator is for pointers to the object, the . is for the object itself. My guess is that the compiler goes "Hey look, it''s constant! Nevermind that it''s part of the class..." and lets you do it. ;quote:Original post by Raloth  quote:Original post by PlayGGY   Woah, are you creating a Foo anywhere?  Because the .  operator shouldn''t work on a class, only on an object.  Try Foo->Constant .   ...the -> operator is for pointers to the object, the . is for the object itself. My guess is that the compiler goes "Hey look, it''s constant! Nevermind that it''s part of the class..." and lets you do it.   I realize ->   is for pointers... I was just seeing how far the compiler let you go before it wouldn''t allow it. ;  Wow, thats something I haven''t come across. Pretty weird since you claim no instantiation of foo. Maybe I''ll have to try it out in .net to see what happens. ;quote:Original post by Nervo   Wow, thats something I haven't come across. Pretty weird since you claim no instantiation of foo. Maybe I'll have to try it out in .net to see what happens.   tell me once you know it works in .net or not.   [edited by - alnite on February 18, 2004 12:03:49 AM];  ------ Build started: Project: craptest2, Configuration: Debug Win32 ------Compiling...mainsrc.cppc:\Documents and Settings\Owner\My Documents\Visual Studio Projects\TestProjects\craptest2\mainsrc.cpp(15) : warning C4832: token ''.'' is illegal after UDT ''Foo''   c:\Documents and Settings\Owner\My Documents\Visual Studio Projects\TestProjects\craptest2\mainsrc.cpp(7) : see declaration of ''Foo''thats with using ''.'' to access a the member variable. It does compile just shows the warning.of course, using the scope operator shows no compiler errors when compiling the code. 