Visual Studio Transfer Control bypasses the startup of:

Asked

Viewed 149 times

-1

switch (option) {
case 1:
    int var;
    std::vector<int>v(size);
    std::list<int>l;

    std::cout << "Digite os elementos do container (vector): ";
    for (int i = 0; i < size; i++) {
        std::cin >> v[i];
    }

    std::cout << "Digite os elementos do container (list): ";
    for (int i = 0; i < size; i++) {
        std::cin >> var;
        l.push_front(var);
    }

    bubbleSort(v);
    bubbleSort(l);

    for (auto x : v) {
        std::cout << x << " ";
    }
    std::cout << "\n";
    for (auto x : l) {
        std::cout << x << " ";
    }
    std::cout << "\n";

    break;
case 2:
    double var;
    std::vector<double>v(size);
    std::list<double>l;

    std::cout << "Digite os elementos do container (vector): ";
    for (int i = 0; i < size; i++) {
        std::cin >> v[i];
    }

    std::cout << "Digite os elementos do container (list): ";
    for (int i = 0; i < size; i++) {
        std::cin >> var;
        l.push_front(var);
    }

    bubbleSort(v);
    bubbleSort(l);

    for (auto x : v) {
        std::cout << x << " ";
    }
    std::cout << "\n";
    for (auto x : l) {
        std::cout << x << " ";
    }
    std::cout << "\n";

    break;
case 3:
    char var;
    std::vector<char>v(size);
    std::list<char>l;

    std::cout << "Digite os elementos do container (vector): ";
    for (int i = 0; i < size; i++) {
        std::cin >> v[i];
    }

    std::cout << "Digite os elementos do container (list): ";
    for (int i = 0; i < size; i++) {
        std::cin >> var;
        l.push_front(var);
    }

    bubbleSort(v);
    bubbleSort(l);

    for (auto x : v) {
        std::cout << x << " ";
    }
    std::cout << "\n";
    for (auto x : l) {
        std::cout << x << " ";
    }
    std::cout << "\n";

    break;
}

Why am I getting this message ? What would that be?

Error (active):
variable "v" (declared in row 29) variable "l" (declared in row 30) variable "v" (declared in row 58) variable "l" (declared in row 59)

1 answer

0


Put keys in each "case":

switch (option) {
  case 1:
  {
    int var;
    std::vector<int>v(size);
    std::list<int>l;
    //...
    //...
    break;
  }

  case 2:
  {
    double var;
    std::vector<double>v(size);
    std::list<double>l;
    //...
    //...
    break;
  }

  case 3:
  {
    char var;
    std::vector<char>v(size);
    std::list<char>l;
    //...
    //...
    break;
  }

} // switch

Why am I getting this message ? What would that be?

  • The problem was solved fought by the help! D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.