simvol = 60; // т.е. имеется в виду код символа "<" int simvol_email::left(QChar simvol) { int x = 1; if (simvol > 64 and simvol < 91) x = 0; { x = 0; return x; // если ноль то символ допустим } return x; } 
  • And then if (simvol > 64 and simvol < 91) x = 0; semicolon exactly needed? - Donil

1 answer 1

Rewrite the code more clearly.

 int simvol_email::left(QChar simvol) { int x = 1; if (simvol > 64 and simvol < 91) x = 0; // Здесь если символ от 65 до 90 включительно, `x` становится равным 0. { // Новый блок, но т.к. в нем `x` не объявлена, то это та же `x`, что и вне блока... x = 0; // Теперь `x` БЕЗУСЛОВНО равно 0 return x; // если ноль то символ допустим // И так же безусловно оно и возвращается... } return x; // Сюда поток выполнения никогда не доберется. } 

So, not the dumbest compiler optimizes this function as

 int simvol_email::left(QChar simvol) { return 0; } 

To explain in more detail, I think it is not necessary?

PS You can immediately see a novice programmer know how? Any of your mistakes immediately follows the statement "BAG B ... !!!!". Yes, there are bugs in this software. But much less often than you think.

The principle of presumption of correctness of the compiler and libraries is one of the first rules to be learned. The compiler and libraries are sinless :) until proven otherwise.

  • Thank you for the clarification. Long soared over such nonsense, the conclusion must sometimes rest. - shaman888