vendredi 13 décembre 2019

How to code the auto& in a if else or switch case format?

I used to have a code to extract certain part 'auto& c = m_matrix[name];' now I have to use a if/else or switch case for m_matrix options like the following switch input: case 1: auto& c = A[name]; case 2: auto& c = B[name]; end However, this is wrong as it will show that the definition of c is duplicated. At the same time, I can't declare auto& c; before switch/case as well. Is there a way to solve this problem? Thanks for help.

Aucun commentaire:

Enregistrer un commentaire