Comparing arrays of objects with arrays of fields of objects
<p>Is there a good way to compare arr[i].A to A[i] and arr[i].B to B? </p>

<pre><code>int A[10], B[10];

class Foo {
   int A, B;
};

Foo arr[10];
</code></pre>

<p>I could do the following:</p>

<pre><code>for (i=0;i&lt;10;i++) {
   if (A[i] == arr[i].A) {}
   if (B[i] == arr[i].B) {}
}
</code></pre>

<p>But, this is painful especially if there are a lot of fields, and the if() conditional does the same thing over and over, there will be a lot of code duplication. What I really want to do is parametrize this somehow and call a function like (test(A,arr)). I guess I can solve this by using #define macros, but that seems ugly. </p>

<p>Any suggestions?</p>

<p>Also I want to avoid creating a new array of Foo objects because I don't want to create new objects that may have many fields I don't care about, also I may want to compare different subsets of fields.</p>
