user33435: I'm looking to create a factory pattern to identify which of N objects is attached to my Serial port. Assuming each object has a unique response to the input stream "What topic is this?", How can I get my ScienceFactory class to create my Science subclasses?
EDIT 2 To clarify, 

Arduino sends identification query to device.   
Device responds withidentification string 
Arduino receives identification string
Arduino constructs correct Science Child

Looking at various examples, I've been able to get the following skeleton code:
class ScienceFactoy
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      bool GetTopic();
};

bool ScienceFactoy::GetTopic()
{
    Serial.println("What Topic is this?");
    /*The Device will respond with "Biology", "Chemestry" or "Physics"
    over Serial*/

    Topic=Biology;
      /*Instead of writing the Serial.read() logic, 
      let's pretend the device is a Biology device*/

    if(Topic==Biology)
    {
        //Create Biology Science Class
        return true;
    }
    if(Topic==Chemistry)
    {
        //Create Chemistry Science Class
        return true;
    }
    if(Topic==Physics)
    {
        //Create Physics Science Class
        return true;
    }
    else
    {
        return false;
    }
}

class Science
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      //bool takeAttendance()
      //virtual void TestStudents();
      //virtual void PopQuiz();
      virtual void Free() = 0;
};

class Biology : public Science
{
    public:
    Biology(){Serial.println("Ready For Bio");}
      //bool DissectFrogs(){}
};

class Chemistry : public Science
{
    public:
    Chemistry(){Serial.println("Ready For Chem");}
      //bool MixChemicals(){}
};

class Physics : public Science
{
    public:
    Physics(){Serial.println("Ready For Physics");}
      //bool OpticsLab(){}
};

Science ConnectedClass;

void setup() {
  Serial.begin(9600);
  ScienceFactory ClassAtSerialPort; /*(Something happens that redefines 
  ClassAtSerialPort to be the correct class)*/
  /*SerialOut "Ready For Bio\n" should happen here*/
  ConnectedClass=ClassAtSerialPort;

}

void loop() {
  if(ConnectedClass.Topic==Biology){DissectFrogs();};

}

However, I don't know where to go from here as my code is Arduino specific. (Edit changed the code so to something that compiles)

user42061: This is not a simple solution because of the way your Factory and Science classes are structured.
Your Science class needs to hold an actual instance of itself for use when the loop wants to call the children.  This instance will be called 'device' in my example. 
class Science
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      //bool takeAttendance()
      //virtual void TestStudents();
      //virtual void PopQuiz();
      virtual void Free() = 0;
      Science* device;
};

In your GetTopic() call you then need to instantiate the actual child class
if(Topic==Biology)
{
    //Create Biology Science Class
    device = new Biology(); // with appropriate parms
    return true;
}

Then in your setup() you have to use the class that was created
ConnectedClass=ClassAtSerialPort.device;

So in the loop() code you call call the device specific method.  
void loop() {
  if(ConnectedClass.Topic==Biology){connectedClass.doScience();};

}

There is problem with your approach you might still need to resolve.  Relying on polymorphism like this is typically done by creating a common method in the parent that all the children override (ex. doScience()) and each child class does whatever is appropriate.  You can have class specific methods but then you'll likely need to cast the device to the specifc class first.

33435: <p>I'm looking to create a <a href="https://www.c-sharpcorner.com/UploadFile/napanchal/factory-pattern-in-VB-Net/" rel="nofollow noreferrer">factory pattern</a> to identify which of N objects is attached to my <code>Serial</code> port. Assuming each object has a unique response to the input stream <code>"What topic is this?"</code>, How can I get my <code>ScienceFactory</code> class to create my <code>Science</code> subclasses?</p>

<p><strong>EDIT 2</strong> To clarify, </p>

<ul>
<li><em>Arduino</em> sends <code>identification query</code> to <em>device</em>.   </li>
<li><em>Device</em> responds with<code>identification string</code> </li>
<li><em>Arduino</em> receives <code>identification string</code></li>
<li><em>Arduino</em> constructs correct <code>Science Child</code></li>
</ul>

<p>Looking at various examples, I've been able to get the following skeleton code:</p>

<pre><code>class ScienceFactoy
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      bool GetTopic();
};

bool ScienceFactoy::GetTopic()
{
    Serial.println("What Topic is this?");
    /*The Device will respond with "Biology", "Chemestry" or "Physics"
    over Serial*/

    Topic=Biology;
      /*Instead of writing the Serial.read() logic, 
      let's pretend the device is a Biology device*/

    if(Topic==Biology)
    {
        //Create Biology Science Class
        return true;
    }
    if(Topic==Chemistry)
    {
        //Create Chemistry Science Class
        return true;
    }
    if(Topic==Physics)
    {
        //Create Physics Science Class
        return true;
    }
    else
    {
        return false;
    }
}

class Science
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      //bool takeAttendance()
      //virtual void TestStudents();
      //virtual void PopQuiz();
      virtual void Free() = 0;
};

class Biology : public Science
{
    public:
    Biology(){Serial.println("Ready For Bio");}
      //bool DissectFrogs(){}
};

class Chemistry : public Science
{
    public:
    Chemistry(){Serial.println("Ready For Chem");}
      //bool MixChemicals(){}
};

class Physics : public Science
{
    public:
    Physics(){Serial.println("Ready For Physics");}
      //bool OpticsLab(){}
};

Science ConnectedClass;

void setup() {
  Serial.begin(9600);
  ScienceFactory ClassAtSerialPort; /*(Something happens that redefines 
  ClassAtSerialPort to be the correct class)*/
  /*SerialOut "Ready For Bio\n" should happen here*/
  ConnectedClass=ClassAtSerialPort;

}

void loop() {
  if(ConnectedClass.Topic==Biology){DissectFrogs();};

}
</code></pre>

<p>However, I don't know where to go from here as my code is Arduino specific. (<strong>Edit</strong> changed the code so to something that compiles)</p>
 42061: <p>This is not a simple solution because of the way your Factory and Science classes are structured.</p>

<p>Your Science class needs to hold an actual instance of itself for use when the loop wants to call the children.  This instance will be called 'device' in my example. </p>

<pre><code>class Science
{
    public:
      enum Subject {Biology, Chemistry, Physics};
      enum Subject Topic;
      //bool takeAttendance()
      //virtual void TestStudents();
      //virtual void PopQuiz();
      virtual void Free() = 0;
      Science* device;
};
</code></pre>

<p>In your GetTopic() call you then need to instantiate the actual child class</p>

<pre><code>if(Topic==Biology)
{
    //Create Biology Science Class
    device = new Biology(); // with appropriate parms
    return true;
}
</code></pre>

<p>Then in your setup() you have to use the class that was created</p>

<pre><code>ConnectedClass=ClassAtSerialPort.device;
</code></pre>

<p>So in the loop() code you call call the device specific method.  </p>

<pre><code>void loop() {
  if(ConnectedClass.Topic==Biology){connectedClass.doScience();};

}
</code></pre>

<p>There is problem with your approach you might still need to resolve.  Relying on polymorphism like this is typically done by creating a common method in the parent that all the children override (ex. <code>doScience()</code>) and each child class does whatever is appropriate.  You can have class specific methods but then you'll likely need to cast the device to the specifc class first.</p>
