The problem is all because of the second line here:
#include <algorithm>
using namespace std;
The line using namespace std
brings all the names from <algorithm>
which also has a function called count
, and in your code, you've declared a variable count
. Hence the ambiguous error.
The solution is to never write using namespace std
. It is bad bad bad.
Instead, use std::cout
, std::cin
, std::endl
, std::count
and so on, in your code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…