And the part which does the real work, function calc(). Current version: 1 2 3 4 5 6 7 8 9 10 11 void reshte::calc() { while (*s) { if (*s==x) { c++; s++; } } } Well, there's an ambiguity there, We have two different variables, each named 's' (the cause of the compiler error). Which one is this meant to refer to? There's also a problem that when the if condition is false, the values of c and s are not incremented, thus the next time around the same values will be tested again, and an infinite loop results.