Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Keyword to indicate that a class variable can be changed in a const method.
In class design mutable variables say nothing about a class, but are used for bookkeeping tasks.
When a neural network responds to a certain input, it will produce a certain output. The flow of information from input layer to output layer is called propagation. During propagation, the neural network must not be changed. Therefore, in class design the propagation method must be a const method. If the last input must be stored (for back-propagation for example), this must be done with mutable.
struct Input { /* some structure to store neural net inputs */ };
struct Output { /* some structure to store neural net outputs */ };
struct NeuralNet
{
//Propagate must be a const method
const Output Propagate(const Input& input) const
{
m_last_input = input; //Store last input
//Perform actual propagation
}
mutable Input m_last_input; //Last input must be mutable
};
[0] ...
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.