Sunday, March 17, 2013

Nesting Classes

#include<iostream>
using namespace std;
class A{
           int m;
           class B{
                      int n;
                      public:
                      void setdata()
                      {
                          n=10;
                      }
                  };
            public:
            void getdata()
            {
                B ob;
                ob.setdata();
            }
            void display()
            {
                cout<<m;
            }
        };

int main()
{
    A ob1;
    ob1.getdata();
    ob1.display();
    return 0;
}

0 comments:

Post a Comment