problem with assignment in a function of class

The following function SignalChangedEvent(theSimulation.time + delay, outputWires, outputValue, i) has to be implemented.

I have written the following:
1
2
3
4
5
6
7
SignalChangedEvent(unsigned int t, std::vector<Wire*> &  vec, bool lala, unsigned int sample)
{
	time= t;
	value = lala;
	vec[sample].setValue(value);

}


The Wire* part refers to this class:
1
2
3
4
5
6
7
8
9
10
11
class Wire {
private:
	Component& component;
	int inputBitNum;
	bool value;
public:
	Wire(Component& c, int i) : component(c), inputBitNum(i), value(false) { }
	void process(Component& );

	void setValue(bool v) {value = v;}
};


In the implementation of the function SignalChangedEvent, i get this long error:
|error: request for member 'setValue' in '((std::vector<Wire*, std::allocator<Wire*> >*)vec)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = Wire*, _Alloc = std::allocator<Wire*>](sample)', which is of non-class type 'Wire*'|

Is there a different way to write vec[sample].setValue(value) to avoid this mess?
Thanks in advance.
vec[sample] returns a pointer to a Wire, so to access members and methods you need to either dereference that pointer and then use the . operator, or simply use the -> operator.
Thanks!! :D I just lost track of the stuff through all the mess.
Topic archived. No new replies allowed.