class CNpc { private: int health; int attackPower; bool isAggressive; public: CNpc(int health, int attackPower, bool isAggressive) { this->health = health; this->attackPower = attackPower; this->isAggressive = isAggressive; } void attack() { cout << "NPC attacks for " << attackPower << " damage." << endl; } };
CNpc* npc = new CNpc(50, 10, true); npc->attack();This code creates an object of CNpc class and passes its attributes as arguments in the constructor. Then it calls an attack function on the object, which prints an NPC's attack power to the console. Based on the usage of this class in the examples above, it seems that CNpc is most commonly found in game development libraries such as Unreal Engine, Unity, and CryEngine.