Array data-handling with NPC class I am wondering about the best way to save on RAM/memory when there are many required arrays (I plan to have many more NPCs and various other arrays with text and items). And I am wondering what I can improve on so far.

  #include &lt;iostream&gt;
  #include &lt;cstring&gt;

  #define NUM_NPC 10       // Number of NPC players

  #define DETAILS_HEARTS 0 // Heart Position
  #define DETAILS_BDMON  1 // Birthday Month Position
  #define DETAILS_BDDAY  2 // Birthday Day Position
  #define DETAILS_GENDER 3 // NPC Gender

  using namespace std;

  class npcPlayers {
     public:
        int getHearts(int playerID);
        int getItem(int playerID, int itemID);
        int getBirthdayMonth(int playerID);
        int getBirthdayDay(int playerID);
        char *getName(int playerID);
        npcPlayers();
     private:
        int npcDetails[NUM_NPC][10];
        char npcNames[NUM_NPC][20];
        int updateHearts(int PlayerID,int value);
  };

  npcPlayers::npcPlayers() {
     npcNames = {"Ace","Amber","Benny","Ethan","Michael","Jay","William","Mia","Chloe","Emily"};
     npcDetails = {
        {0,3,5,0},    // Ace
        {0,9,20,1},   // Amber
        {0,1,10,0},   // Bennny
        {0,12,30,0},  // Ethan
        {0,2,17,0},   // Michael
        {0,6,10,0},   // Jay
        {0,8,9,0},    // William
        {0,4,1,1},    // Mia
        {0,5,13,1},   // Chloe
        {0,8,5,1}     // Emily
     };
  }

  int npcPlayers::getHearts(int playerID) {
     return npcDetails[playerID][DETAILS_HEARTS];
  }
  int npcPlayers::getItem(int playerID, int itemID) {

  }
  int npcPlayers::getBirthdayDay(int playerID) {
     return npcDetails[playerID][DETAILS_BDDAY];
  }
  int npcPlayers::getBirthdayMonth(int playerID) {
     return npcDetails[playerID][DETAILS_BDMON];
  }
  char *npcPlayers::getName(int playerID) {
     return npcNames[playerID];
  }

  int main() {
     npcPlayers npc;
     cout &lt;&lt; "Player 1 Details:" &lt;&lt; endl;
     cout &lt;&lt; "Name: " &lt;&lt; npc.getName(1) &lt;&lt; endl;
     cout &lt;&lt; "Hearts: " &lt;&lt; npc.getHearts(1) &lt;&lt; endl;
     cout &lt;&lt; "Birthday: " &lt;&lt; npc.getBirthdayMonth(1) &lt;&lt; "/" &lt;&lt; npc.getBirthdayDay(1) &lt;&lt; endl;
     return 0;
  }
C++ is statically typed programming language. Due to this overhead for allocation of class members is very small.
Using of global variables is not a good idea. Such vars like NUM_NPC makes your application non-scalable.
Each domain object (like a player or an item) must be described by a same-named class.




#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

typedef int Hearts;
typedef bool Gender;

struct Date
{
      Date(int month,int day) : month(month), day(day) {}
      int month;
      int day;
};

class Item
{
    // TODO: implement
};

class Player
{
public:
      Player(std::string name, Hearts hearts, Date birthday, Gender gender)
            : name(name), hearts(hearts), birthday(birthday), gender(gender) {}

      Hearts getHearts() const
      {
            return hearts;
      }

      const std::vector&lt;Item&gt;&amp; getItems()
      {
            return items;
      }

      Date getBirthday() const
      {
            return birthday;
      }

      std::string getName() const
      {
            return name;
      }
private:
      std::vector&lt;Item&gt; items;
      Hearts hearts;
      Date birthday;
      std::string name;
      Gender gender;
};

int main()
{
      using namespace std;

      vector&lt;Player&gt; players;
      players.push_back(Player("Ace", 0, Date(3,5), 0));
      players.push_back(Player("Amber", 0, Date(9,20), 1));
      players.push_back(Player("Benny", 0, Date(1,10), 0));
      players.push_back(Player("Ethan", 0, Date(12,30), 0));

      Player&amp; p = players[1];
      cout &lt;&lt; "Player 1 Details:" &lt;&lt; endl;
      cout &lt;&lt; "Name: " &lt;&lt; p.getName() &lt;&lt; endl;
      cout &lt;&lt; "Hearts: " &lt;&lt; p.getHearts() &lt;&lt; endl;
      cout &lt;&lt; "Birthday: " &lt;&lt; p.getBirthday().month &lt;&lt; "/" &lt;&lt; p.getBirthday().day &lt;&lt; endl;
      cout &lt;&lt; "Item count: " &lt;&lt; p.getItems().size() &lt;&lt; endl;
}