I have a class called CircuitProfiler that has a public member function switchState. Below is the code for it:
void CircuitProfiler::switchState(int index)
{
if (profilingNode)
{
switch (index)
{
case 0:
node->getVoltage().isKnown = !node->getVoltage().isKnown;
break;
}
}
}
The code I am having trouble with is the line:
node->getVoltage().isKnown = !node->getVoltage().isKnown;
I am getting error that says "expression must be a modifiable lvalue". There is a red line under node.
node is a pointer to an instance of a Node class that I created. node a private data member of CircuitProfiler. It is declared in CircuitProfiler as Node* node;
Node has a private data member called voltage, and getVoltage is a public member function of Node that simply returns voltage. voltage is declared in Node as VariableValue<float> voltage;
and the code for getVoltage is:
VariableValue<float> Node::getVoltage()
{
return voltage;
}
voltage is an instance of a simple struct called VariableValue, the code for which is below.
template <class T>
struct VariableValue {
T value;
bool isKnown;
};
So why am I getting the error "expression must be a modifiable value"? Let me know if I need to provide any more information.