Account class design using OOP paradigm I have a class Accounts with an array of account numbers and an array of balances I have a member function add_acc that adds an account. But before adding an account, I want to check if the account no. to be added, already exists or not. If it exists then an error message is displayed else the new account is added. In my following class design, the compiler is not able to check for the uniqueness of the account no. when more than 1 accounts are being added. Following is my approach.
#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
using namespace std;
#define MAX 100
class Account
{
    long long int acc_no[MAX];
    long long int balance[MAX];
    int count;
    public :
        void CNT()
        {
            count=0;
        }
        void add_acc();

};
void Account::add_acc()
{
    if(count==0)
    {
        cout&lt;&lt;&quot;Enter the account number&quot;&lt;&lt;&quot; : &quot;;
        cin&gt;&gt;acc_no[count];
        cout&lt;&lt;&quot;Enter the balance&quot;&lt;&lt;&quot; : &quot;;
        cin&gt;&gt;balance[count];
    }
    else
    {
        long long int temp;
        cout&lt;&lt;&quot;Enter the account no. to be added : &quot;;
        cin&gt;&gt;temp;
        for(int i=0;i&lt;count;i++)
        {
            if(temp==acc_no[i])
            {
                cout&lt;&lt;&quot;Account no. already exists&quot;&lt;&lt;&quot;\n&quot;;
                return;
            }
            else
            {
                continue;
            }
            
        }
        temp=acc_no[count];
        cout&lt;&lt;&quot;Enter the balance : &quot;;
        cin&gt;&gt;balance[count];

    }
    count++;
}
int main()
{
    Account A;
    A.CNT();
    char ch;
    while(ch)
    {
        A.add_acc();
        cout&lt;&lt;&quot;Want to add another account? : &quot;;
        cin&gt;&gt;ch;
        if(ch=='Y' || ch=='y')
            continue;
        else
            break;
     }
    return 0;
}

The problem with my output -:
In the first run I entered the account no. as 123, int the second run I enter the acc. no. as 345 and when in the third run again I entered the acc. no. as 345, the error message was not displayed.
Use unordered_map to maintain account number and balance.
You can use unordered_map(hash table) for checking if an acc_num already exists or not and the membership check in unordered_map is O(1).
You can use int64_t for long long int
You can int64_t for long long int, uint64_t for unsigned long long int and since bank balance can't be less than 0 use uint64_t for balance.
count is unnecessary, use unordered_map::find.
You can eliminate count when you are using unordered_map to check if acc_num exists use unordered_map::find.
Create alias using using.
using account_table not only allows you to give a short name to a complex type, but it puts the type definition in a single place. Then if you change the underlying type you only need to change it in that one place.
Avoid using using namespace std;
Find more details here why using namespace std; is considered bad praactice
I added Account::print_details, it prints acc_num --&gt; balance
Refactored code
#include&lt;iostream&gt;
#include&lt;unordered_map&gt;
#include&lt;string&gt;

class Account{
    using account_table = std::unordered_map&lt;std::string, uint64_t&gt;;
    private:
        account_table table;
    public:
        void add_acc();
        void print_details();
};

void Account::add_acc(){
    std::cout&lt;&lt;&quot;Enter account number : &quot;;
    std::string acc_num;
    std::cin&gt;&gt;acc_num;
    if (table.find(acc_num)==table.end()){
        uint64_t balance;
        std::cout&lt;&lt;&quot;Enter balance : &quot;;
        std::cin&gt;&gt;balance;
        table.insert({acc_num, balance});
    }
    else{
        std::cout&lt;&lt;&quot;Account number already exists\n&quot;;
    }
}

void Account::print_details(){
    for(auto&amp; d: table){
        std::cout&lt;&lt;d.first&lt;&lt;&quot;--&gt;&quot;&lt;&lt;d.second&lt;&lt;std::endl;
    }
}

int main(){
    Account A;
    char ch{'Y'};
    
    while(ch){
        A.add_acc();
        std::cout&lt;&lt;&quot;Want to add another account : &quot;;
        std::cin&gt;&gt;ch;
        if (ch!='Y' &amp;&amp; ch!='y'){
            break;
        }
    }
    A.print_details();
    return 0;
}

Example run
Enter account number : 1234
Enter balance : 50
Want to add another account : y
Enter account number : 1234
Account number already exists
Want to add another account : Y
Enter account number : 12345
Enter balance : 12
Want to add another account : n
12345--&gt;12
1234--&gt;50


You can use clang-format-9(code formatting tool)
Example:
clang-format-9 -i -style=Google your_file.cpp