   Nesting structs and classes within classes in C++: Some Questions...
  I'm at a computer without VS C++ installed. I'm grounded from using my own computer, due to lack of sleep and making my parents mad at my behavior.1. From this code below, I know I can do this:struct Temp {   int x;   int y;};class SomeClass{   Temp Speed;};Can we do:class SomeClass{   struct Temp   { int x; int y;    };};SomeClass::SomeClass{   Temp::x = 0;   Temp::y = 0;}Like that? If not, what should I change to make it work?2. As for nested classes, can I do this?class ClassB{public:    int Temp;}class ClassA{   ClassB Holder;};ClassA::ClassA{   ClassB::ClassB   { //Do something about Temp.   }   //Do something about Holder.}Thanks in advance. It's something my professor wouldn't answer, since it's out of our curriculum of this semester.   
Quote:Original post by tom_mai78101Can we do:*** Source Snippet Removed ***I assume that SomeClass::SomeClass() is a constructor call, so:(Oh and, you are forgetting about constructor declarations.)class SomeClass{   SomeClass( );   struct Temp   { int x; int y;    } temp;};SomeClass::SomeClass( ){    temp.x = 0;    temp.y = 0;}Quote:2. As for nested classes, can I do this?*** Source Snippet Removed ***You can't nest methods/constructors like that, you would have to separate them:class ClassB{    ClassB( );public:    int Temp;}class ClassA{   ClassA( );   ClassB Holder;};ClassB::ClassB(){    //Do something about Temp.}ClassA::ClassA(){   //Do something about Holder.}Or nest *the whole* definition:class ClassA{   ClassA( );   class ClassB   { ClassB( );   public: int Temp;   };   ClassB Holder;};ClassA::ClassB::ClassB(){    //Do something about Temp.}ClassA::ClassA(){   //Do something about Holder.};  Moved to For Beginners.   ;  A nested class isn't much different from a non-nested class, except that it's in the scope of the enclosing class.  So if you had this:class A { class B {}; };You would always have to use A::B instead of just B whenever you wanted to refer to the nested class.  The relevant portions of the standard are sections 9.7 and 9.9.   ;  Thanks for a lot of info.   