Are you allowed to have pointers to some int and have that same pointer array act as a normal array later on in the program?
Here is what I'm supposed to do:
Implement addFish, which (dynamically) adds a new Goldfish into the Aquarium, with the specified memory capacity. If the fish cannot be added because the Aquarium already has MAX_Fish many fish residing, return false and don't add any. Otherwise, return true.
constint MAX_FISH = 20;
class Aquarium
{
public:
Aquarium();
bool addFish(int capacity);
Goldfish *getFish(int n);
void oracle();
~Aquarium();
private:
Goldfish *m_fish[MAX_FISH]; // <------- here is a pointer
int m_nFish;
};
bool Aquarium::addFish(int capacity)
{
if (m_nFish >= 20)
returnfalse;
else
m_fish[m_nFish] = new Goldish(capacity); // how can we say m_fish here if it was a pointer (where i put the other comment)
m_nFish++;
returntrue;
}