I think the best way for me to explain this is to show you guys what im trying to do.

#include <iostream>
class customer
{
	int CustID;

public:
	void CCustRecords(int NumOfCust)
	{
            x = NumOfCust;
	    for(int i = 0; i < x; ++i)
	    {
		cout << "Enter the Customers ID number. " << endl;
		cin >> CID;
		CID[i].CustID = CID;
            }
        }
};

void main()
{
        int NumOfCust, EmployeeID;
	Employee emp;
	customer cust;
                
	cout << "Welcome to the MED Recorde Managemant System" << endl;
	cout << "--------------------------------------------" << endl;
	cout << endl << "Authorized Personel Only" << endl;
	cout << "Please Enter your Employee ID code " << endl;
	cin >> EmployeeID;

	if(EmployeeID == emp.EmployeeID)
	{
	    cout << "Please enter the number of Customers you want" << endl;
	    cin >> NumOfCust;
            
            cust.CCustRecords(int NumOfCust);
	    customer *CID = new customer[NumOfCust];
            
            cout << endl << endl << endl;
            cout << "Access  Granted!" << endl;
	    cout << "----------------" << endl;

	    
		while(iface != 1)
		{  
		    cout << endl << "Please select one of the following" << endl;
		    cout << endl << "1)Creat Customer records" << endl;
                    cout << endl << "2)Exit Program" << endl;
		    			
		    int iface;
		    cin >> iface;

		    if(iface = 1)
		    {
			cust.CCustRecords(int NumOfCust);
			break;
		    }
                    else
                        cout << "Exiting Program" << endl;
			
	       }

	       delete [] CID;
	}
	else	
	    cout << "I'm sorry but you entered the wrong number" << endl;
}

I'm in school and need help trying to input data into the dynamic array thats inside a class. I made a test program that worked but use a structure inside the main function. I dont understand what i'm missing. If you guys could give me a few pointer in the general direction, certain general areas to study, it would help and a brief example but nothing in detail. Ill find those. Thanks for you time. The error i get is: error C2109: subscript requires array or pointer type

Here is one example of a dynamic array inside a class.

#include <iostream>

class T
{
   int size, *array;
public:
   T(int mysize = 1) : size(mysize), array(new int[size])
   {
      std::cout << "size = " << size << '\n';
   }
   ~T() { delete[] array; }
};

int main()
{
   T a, b(5);
   return 0;
}

/* my output
size = 1
size = 5
*/

From what you've shown, it looks a little inside-out; that is, it seems like you want a dynamic array of customers in main, rather than a dynamic array of whatever in a class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.