I think that the best solution is to change the ngClass content with a function, such as:
<div ng-class="myFunction()">hola</div>
Then define a function that do what it is originally specified in the ngClass attribute:
$scope.myFunction = function () { var x = {}; x['a'] = $scope.first; x['b'] = $scope.second; x[$scope.myClass] = $scope.third; return x; };
In this way, the third class is relative to a variable (the other three variables are for reference to first, second and third).
If you you check this jsfiddle, and you press "add C" and then "switch C with D" how the class are swapped:
http://jsfiddle.net/mhonns9d/