title: Design for interaction of child classes
body: <p>I wanted to get some few pointers to below design problem.</p>
  
  <p>Suppose I wanted to write some classes to enumerate USB devices and select particular device and transmit data through it for different platforms.(Just a very rudimentary scenario.More of a design question than anything related to USB). </p>
  
  <p>Now I want to have a device base class for USB devices which can have functions like enumerate_devices, get_particular_device based on a string etc. Now this would be implemented differently on different platforms. So I'll probably have some child classes which will implement this using the platform specific apis.</p>
  
  <p>Now the other class I want to have will be some buffer class that will transfer data to USB endpoint. This again will need to be implemented by different platforms based on the apis they provide. </p>
  
  <p>Now suppose I create a Windows based USB device class and a buffer class and implement those using Windows provided apis. My question is what do I do if my Windows buffer class needs some data from my Windows device class. What kind of pattern can I use so that the base classes remain anonymous to the internal intermediate platform based structures used in child classes and yet buffer class can use particular device class data members? Want to get a good design for this. Dont know if I am clear enough in writing. Hope to get some insight.</p>
  
  <p>Edit: I know factory and abstract factory. This is not related to them. I cant access child class member function through factory patterns through an object of UsbDevice*</p>
  
  <p>Brief outline.</p>
  
  <pre><code>SomeWindowsUsbDevice : public UsbDevice {
      public:
          void findDevices() {  // just a child class function. Not in base class
              //Code to find devices using platform apis.
              //fills below two private structures.
          }
      private:
          DevEnum* pdevenum; //some platform specific structure.
          Buffsize* pbufsize; // some platform specific structure.
  }
  
  SomeWindowsUsbDataTrf :  public UsbDataTrf {
      public:
          DevEnum* getdevicelist() {
              //Need to get access to SomeWindowsUsbDevice::pdevenum
  
          }
  
          Buffsize* getbuffsize() {
              //Need to get access to SomeWindowsUsbDevice::pdevenum
          }
  
  }
  </code></pre>