Hello everybody and thanks for your help! :-)
I'm trying to write a simple code which has two classes: LogicGate and CircuitDescription.
CircuitDescription contains a vector of inputs (vector<bool> _inputs_vector) and a vector of pointers to LogicGate objects (vector<LogicGate *> _gates_vector).
Every LogicGate objects has its own input vector of pointers to bool (vector<bool *> _own_input_vector).
I want every cell of _own_input_vector to contain the address (should I say "reference"?) of a single cell of _inputs_vector, but when I try to assign the address I receive two errors:
- error: taking addres of temporary [-fpermissive]
- error: cannot convert 'std::vector<bool>::reference* {aka std::_Bit_reference*}' to 'bool*' in assigment
If I change every type from bool to int, for example, everything works well.
This is the part of .cpp (of the class CircuitDescription) in which I try to do the assignment
1 2 3
|
// 'i' is an integer
_own_input_vector.at(i) = &_inputs_vector.at(i);
|
If you want, this is the whole function.
I have to know if I have to point to the _inputs_vector or to the another vector of inputs called "nets".
The function read from a vector of string in which the information is coded as "I3" "N2" "I0", where the letter determines the vector (input or net) and the number is the position in the vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
void CircuitDescription::set_input_vector(vector<string> &input_vector, LogicGate &theGate)
{
vector<string> *pointer_to_input_vector = &input_vector;
vector<string>::iterator it_vector = pointer_to_input_vector -> begin();
string cella;
vector<bool *>::iterator it_input_cella = theGate._inputVector.begin();
while (it_vector != pointer_to_input_vector -> end())
{
cella = *it_vector;
if (cella.at(0) == 'I')
{
*it_input_cella = &_circuit_inputs_vector.at(cella.at(1));
}
if (cella.at(0) == 'N')
{
*it_input_cella = & _circuit_nets_vector.at(cella.at(1));
}
it_input_cella++;
it_vector++;
}
}
|