I am looking for a better way to do something like this:
class variable{
protected:
variable()
int convert[][]
}
class weight: variable{
public:
weight(){
convert = {{1,2},{1,3},{2,5}}
}
Now I know that I can’t do this, because I have to declare the size of the array in advance. I have many classes, all inheriting from a variable of the base class, and the variable has a function that uses convert, so I do not want to declare the conversion in each separately. For each class, the length of the array will remain constant, so using a list seems unnecessary. What are your suggestions.
Many thanks.
source
share