How can I check whether multiple variables are equal to the same value?

How do I compare multiple items? For example, I wish to check if all the variables A, B, and C are equal to the char 'X' or all three are equal to 'O'. (If 2 of them are X and one is O it should return false.)

I tried:

if (A, B, C == 'X' || A, B, C == 'O') 
  {
    //Do whatever
  }

but it didn't work. What is the best way to do this?


if((A == 'X' || A == 'O') && A == B && B == C)
{
    // Do whatever
}

Just for variety:

template <typename T, typename U>
bool allequal(const T &t, const U &u) {
    return t == u;
}

template <typename T, typename U, typename... Others>
bool allequal(const T &t, const U &u, Others const &... args) {
    return (t == u) && allequal(u, args...);
}

if (allequal(a,b,c,'X') || allequal(a,b,c,'O')) { ... }