incomplete type is not allowed while trying to create an array of pointers

arrays, c++, include

Solution

Although you can create an array of pointers to forward-declared classes, you cannot create an array with an unknown size. If you want to create the array at runtime, make a pointer to a pointer (which is of course also allowed):

Account **ownedAccounts;
...
// Later on, in the constructor
ownedAccounts = new Account*[numOwnedAccounts];
...
// Later on, in the destructor
delete[] ownedAccounts;

Problem

I created 2 classes, Branch and Account and I want my Branch class have an array of Account pointers, but i fail to do it. It says that "incomplete type is not allowed". What is wrong with my code? ``` #include <string> #include "Account.h" using namespace std; class Branch{ /*--------------------public variables--------------*/ public: Branch(int id, string name); Branch(Branch &br); ~Branch(); Account* ownedAccounts[]; // error at this line string getName(); int getId(); int numberOfBranches; /*--------------------public variables--------------*/ /*--------------------private variables--------------*/ private: int branchId; string branchName; /*--------------------private variables--------------*/ }; ```

Original source