Listing 3: Defines the CNetwork class. This class owns all components and vertices in the circuit.

//  Network.h

#if !defined(AFX_NETWORK_H ... truncated ... __INCLUDED_)
#define AFX_NETWORK_H ... truncated ... __INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Vertex.h"
#include "Component.h"
#include <list>

class CComponentGround;
class CComponentWire;
class CComponentWireKnown;
class CComponentBattery;
class CComponentResistor;
class CComponentResistorUnknown;

class CNetwork  
{
public:
    CNetwork();
    virtual ~CNetwork();

    CVertex * NewVertex();
    CComponentGround * NewComponentGround();
    CComponentWire * NewComponentWire();
    CComponentWireKnown * NewComponentWireKnown();
    CComponentBattery * NewComponentBattery();
    CComponentResistor * NewComponentResistor();
    CComponentResistorUnknown * NewComponentResistorUnknown();

    void AddToSystemPrimary( CEqSystem &rSystem );
    void AddToSystemSecondary( CEqSystem &rSystem );
    void Dump();

private:
    typedef std::list< CVertex * > CVertexList;
    CVertexList m_lVertices;
    typedef std::list< CComponent * > CComponentList;
    CComponentList m_lComponents;
};

#endif // !defined(AFX_NETWORK_H ... truncated ... __INCLUDED_)