CPP/Classes/NestedClasses

From ProgrammingExamples
< CPP
Revision as of 07:48, 23 June 2010 by Daviddoria (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

NestedClasses.cpp

#include <iostream>
 
class Parent
{
  int name;
  class Child
  {
    int school;
    void test()
    {
      //std::cout << this->name; // this doesn't work - Child doesn't have access to Parent's members
    }
  };
};
 
int main(int argc, char *argv[])
{
  Parent MyParent;
 
  return 0;
}