I have a functor like this,
class PrintParentheses
{
public:
PrintParentheses(unsigned pairsCount)
{}
void operator ()() {}
};
Inside main() I am using it like,
#include <iostream>
int main()
{
unsigned pairsCount = 0;
// Error: ‘PrintParentheses pairsCount()’ redeclared as different kind of symbol
PrintParentheses(pairsCount)();
PrintParentheses(5)(); // But this works
}
Error positions are marked inside the code itself. I have tested both GCC-4.6 and clang-3.1. Both are giving the same error.
That’s being read as pairsCount is a function taking no arguments and returning PrintParentheses. Due to what is known as the Most Vexing Parse, this must be treated as a function declaration. Instead, create an object and use it: