Right! I am designing a very simple (text based) digital circuit simulator (it is a university coursework) ...I have created a design, but am not sure whether it will work the way that I want; here is my idea...

I have classes for each of the following; AndGate, OrGate, XorGate and NotGate, I also have a class Circuit (which will store the details for each circuit a user creates). Then I have the application class for the text based GUI.

My idea is to have a vector inside the Circuit class to store logic gate objects. (I know how to create vectors of objects; this is not the problem!!!) ...The problem starts when trying to store objects of different types into a single vector, so I have come up with the idea that by using inheritance, If i create another class; LogicGate, which has functions and variables used by all types of logic gate, I can create inheritted classes from this class, but adding extra functionality and being able to store them into the same vector!

Now, From my ideas and reading about C++ programming (im a novice to OO design!!! ...I have been using C, which i am confident in using; but this program has to be done in C++), I can do the above design, maybe I am wrong, but I have created a smaller scaled down version of the above problem, and when i compile, i get errors saying class redefined, so am having second thoughts about the design!

Is this design one that is valid? is it possible, or do i have to go about the problem in a different way???

class LogicGate definition...
Code:
class LogicGate{
private:
  int theID;
  int parent1;
  int parent2;
  int input1;
  int input2;
  int output;
public:
  LogicGate(int); //constructor Requires just the ID number
  setInputs(int, int);
  setInput1(int);
  setInput2(int);
  int getID();
  int getPID1();
  int getPID2();
  int setPID1();
  int setPID2();
};
Class AndGate Definition:
Code:
#include "LogicGate.cpp" // for inheritance use
class AndGate : LogicGate{
private:
public:
  int getOutput(int int); // for when two inputs are supplied
  int getOutput(); // for when the input variables have already been set
};
...and so on for each of the classes NotGate, OrGate, XorGate are exactly as the AndGate class. When i compile, it tells me that I have already declared the class LogicGate at line 1 inside AndGate class (but to me I am only including it!!!)

Can you please let me know how I can implement the above design? ...Maybe i am thinking stupidly, but Im not sure!!! I've spent ages looking at my book, and it looks ok to me and can't see how im defining LogicGate twice!!!!!!

Thankyou for your time!!!!