C++ class instances
<p>I am working on intro c++ homework, but I am stuck.</p>

<pre><code>Account *GetAccount(int an);

int main()
{
Account *a1,*a2,*b1;
a1=GetAccount(123);
a2=GetAccount(456);
b1=GetAccount(123);
if(a1==b1)
  cout&lt;&lt;"YES"&lt;&lt;endl;
else
  cout&lt;&lt;"NO"&lt;&lt;endl;
</code></pre>

<p>GetAccount method is supposed to check whether the instance already exists with the same account number, if it does, returns that instance.</p>

<p>Only method I can think of is to create array of Account and search for account, then if it doesn't exist, insert new Account in the array. If it exists, returns the pointer to the array.</p>

<p>This method doesn't really seem efficient to me, and is there any other way?</p>
