I have the following data container:
struct Node
{
explicit Node(const std::vector<Data>& _data, const Value& _value): data(_data), value(_value)
{
}
const std::vector<Data> data;
const Value value;
};
I wish to write a mock along these lines:
class MockVisitor: public IVisitor
{
public:
virtual void operator()(const Node& _node)
{
node = _node;
}
Node node;
};
However, I’m getting the error:
error C2582: 'operator =' function is unavailable in 'Node'.
I’m presuming this is because I can only assign to a const Node. Is there anyway for my to cast away this error? Remember this is only a mock class. I’m simply trying to record the value passed into operator()() so I can check it in my unit test.
Since the member variables
dataandvalueare declared as constant, theoperator=is deleted. This is the reason you can not use it, hence the compilation error.This should work :