Hi. I’m trying to develop a program in which I deal with cars as objects of my defined class “Car”. There is a search part in there in which I ask the user according to which category (name, color,…) the search should be done. The user is supposed to enter a number to determine the search type. Then I have used a switch-case statement. The problem is that it draws a red line under the word “switch” with the following error:
“Transfer of control bypasses initialization of:”
I have never encountered such an error before. Could you please explain what this means and what the problem is with my program?
Some further information that could be helpful:
I have passed Car* CarRecord and int n to my search function. The CarRecord is an array which stores objects of class Car and n is the size of the array. (it’s ok. Isn’t it?)
Later I have the following statements in one of the cases:
string Dname; //the search case is according to the name of the desired car
for(int i=0 ; i<n ; i++)
if ( CarRecord[i].Name==Dname )
Is it wrong to do so?