Difference between revisions of "CPP/Classes/NestedClasses"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Created page with '==NestedClasses.cpp== <source lang="cpp"> #include <iostream> class Parent { int name; class Child { int school; void test() { //std::cout << this->name;…')
 
(No difference)

Latest revision as of 08:48, 23 June 2010

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;
}