   C2326 Compiler Error
  I have a small problem that I am trying to figure out.  Now I know that I will have to redesign the code, but I just want an answer to why this is a problem.// header fileclass X{public:  // public functions  void  SomeFunc( );private:  // forward declarations  struct Y;};// implementation filestruct X::Y{  int Z;};void X::SomeFunc( ){  // compiler error on this line  int nSize = sizeof(X::Y::Z);}This type of code works under .NET 7.1, but is no longer valid with .NET 8.0.  Just wondering as to why I am unable to access element Z.  Thanks.[Edited by - Deception666 on December 7, 2005 11:53:06 PM]
  All I'm really asking is to which ISO standard I am breaking.   ;  The X::Y::Z syntax would only be valid if Z were either a nested type or a static member of Y. This is one way of getting the size of Z:void X::SomeFunc( ){  X::Y y;  std::size_t nSize = sizeof(y.Z);}Another, and cleaner way of handling it would be the following:// implementation filestruct X::Y{  typedef int ZType  ZType Z;};void X::SomeFunc( ){  std::size_t nSize = sizeof(X::Y::ZType);}I recommend getting a better understanding of the differences between non-static and static members of classes and structs.;Quote:I recommend getting a better understanding of the differences between non-static and static members of classes and structs.Thank you for putting it so politely, but you still have not answered to which ISO standard I have violated.void X::SomeFunc( ){  X::Y y;  std::size_t nSize = sizeof(y.Z);}Yes, I don't like this approach either.  I shouldn't have to bloat the local function with a constructed object that sits on the stack.struct X::Y{  typedef int ZType  ZType Z;};I understand why this works, but I would assume the standard would allow the sizeof operation to be applied to a non-static member.  The scope resolution would allow me to access the variable to do things like obtaining the size of a variable, but when assigning to that variable the compiler would throw an error.Thanks again.   ;  I have no idea why that compiled under .NET 7.1, because it makes sense to me why it won't work.  The problem is that "Z" is a non-static data member of X::Y, and the only way to get 'Z' is from an instance of X::Y.If you made Z static you'd be able to do X::Y::Z.Now since you said it compiled under 7.1, I'm curious if anyone knows why?  It certainly does not make sense to me why it would.   