I am currently programming a digital circuit simulator program (uni coursework) ...I have created a vector of objects...

vector <LogicGate*> theCircuit;

Inside logic gate there are functions for all logic gates! ...then there are seperate sub-classes that are derrived from class LogicGate to over-ride some functions to give the ability to create different types of logic; and, or, xor, not. My vector can contain any of these classes, this works fine...

So now i have my vector with the above logic gate objects inserted! ...I thought therefore, that i could easily do the following...Code:int Circuit::addGate(int inType){ switch(inType){ case 0 : theCircuit.push_back(new InputGate(newID(), 0)); return 0; case 1 : theCircuit.push_back(new InputGate(newID(), 1)); return 0; case 2 : theCircuit.push_back(new AndGate(newID(), 2)); return 0; case 3 : theCircuit.push_back(new OrGate(newID(), 3)); return 0; case 4 : theCircuit.push_back(new XorGate(newID(), 4)); return 0; case 5 : theCircuit.push_back(new NotGate(newID(), 5)); return 0; default : return -1; } } // NOTE: newID() is a small function that generates (and then returns) unique id codes. // To give you an idea what the values are for constructing logic gates; the constructor for the andgate class... // AndGate::AndGate(int inID, int inType){ .. sets id and logic gate type here .. }

with getType() function being declared in class LogicGate...Code:for (int i=0; i<theCircuit.size(); i++){ // is current gate an input gate? if (theCircuit.at(i).getType() != 0) { ...some code here... } }

However; at compilation i get the error...Code:class LogicGate{ private: int gateType; // The type of logic gate int gateID; // The ID for the logic gate int pID1; // The first parent for the logic gate int pID2; // The second parent for the logic gate int input1; // The first input value for the logic gate int input2; // The second input value for the logic gate int output; // The output value for the logic gate public: // Class Methods: void setID(int); // sets the gate ID number int getType(); // returns the gate type code void setType(int); // sets the gate type code int getID(); // returns gates ID int getPID1(); // returns gates first parent ID int getPID2(); // returns gates second parent ID void setPID1(int); // sets ID of gates first parent void setPID2(int); // sets ID of gates second parent void setInput1(int); // sets gates first input value void setInput2(int); // sets gates second input value int getInput1(); // returns value of first input int getInput2(); // returns value of second input // Virtual Methods: virtual int getOutput(); // returns gates output value };

Its confusing, because to me it appears that this should work fine!!! ...I tried a simpler version using vectors of objects and that worked fine, i could access all the objects functions using the vector.at(x).functionName() with no problems at all!!! so what is going on here??? ...anyone know what i am doing wrong???Code::\WORK\CIRCUIT.CPP(100) : error C2228: left of '.getType' must have class/struct/union type

Cheers!!! Matt..