Search code examples
c++variablesvariable-assignmentcompound-assignment

How can I add multiple numbers to a variable


I'm trying to use += to add multiple numbers to a variable.

I'm trying to do something like this: score += var1, var2, var3

However, the only thing I know how to do now is

score += p;
score += v;
score += t;

Solution

  • You can simply do:

    score += var1 + var2 + var3;