What in my C++ program could be setting off my Norton antivirus? Also struggling to debug and fix an exception, maybe memory related?

I’m taking a C++ class but I’m not completely new to programming as I know a good deal of Java and some Python. This is something I have never seen before: I have a program that supposed to inventory animals on an ark and age them by 1 month and simulate the population growth on the ark. I went through with the debugger and found it works fine until the second fish object goes through the ageOneMonth method, then I get an exception

“Exception thrown at 0x00007FF779B38CBB in noahsArkApp.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.”

The program exits with (process 20984) exited with code -1073741819.

What’s even more weird is each time this happens my Norton antivirus shows a popup “Potential Threat Blocked” The action described in the details is “suspicious process attempted to modify security of a file protected by Data Protector”. What could be going on here? How do I fix this exception? Do I need to disable Norton?

#include <iostream>
#include <string>
#include <vector>
#include <memory> // for smart pointers? Googled for a fix to memory issue but still having problems :(
#include <cstdlib> // for srand() and rand() functions
#include <ctime>   // for time() function

using namespace std;

// enum classes to limit options for type and gender
enum class Type { MAMMAL, BIRD, FISH };
enum class Gender { FEMALE, MALE };

class Animal {
protected:
    Type type;
    string species;
    Gender gender;
    int ageInMonths;

public:
    Type getType() { return type; }
    string getName() { return species; }
    Gender getGender() { return gender; }
    int getAgeInMonths() { return ageInMonths; }

    Animal(Type _type, string _name, Gender _gender, int _ageInMonths) : type(_type), species(_name), gender(_gender), ageInMonths(_ageInMonths) {};

    virtual void ageOneMonth() {
        ageInMonths++;
    }

    virtual void giveBirth(vector<unique_ptr<Animal>>& animals) {
        // Default implementation does nothing
    }

    virtual void identifyAnimal() const {
        string genderStr = (gender == Gender::MALE) ? "male" : "female";
        cout << "I am a " << genderStr << " " << species << ", " << ageInMonths << " months old." << endl;
    }
};

class Mammal : public Animal {
public:
    Mammal(Type _type, string _name, Gender _gender, int _ageInMonths) : Animal(Type::MAMMAL, _name, _gender, _ageInMonths) {}
    virtual void giveBirth(vector<unique_ptr<Animal>>& animals) override {
        if (gender == Gender::FEMALE && ageInMonths % 12 == 0) {
            Gender newbornGender = (rand() % 2 == 0) ? Gender::MALE : Gender::FEMALE;
            animals.push_back(make_unique<Mammal>(getType(), getName(), newbornGender, 0));
        }
    }
};

class Bird : public Animal {
public:
    Bird(Type _type, string _name, Gender _gender, int _ageInMonths) : Animal(Type::BIRD, _name, _gender, _ageInMonths) {}
    virtual void giveBirth(vector<unique_ptr<Animal>>& animals) override {
        if (gender == Gender::FEMALE && ageInMonths % 9 == 0) {
            Gender newbornGender = (rand() % 2 == 0) ? Gender::MALE : Gender::FEMALE;
            animals.push_back(make_unique<Bird>(getType(), getName(), newbornGender, 0));
        }
    }
};

class Fish : public Animal {
public:
    Fish(Type _type, string _name, Gender _gender, int _ageInMonths) : Animal(Type::FISH, _name, _gender, _ageInMonths) {}
    virtual void giveBirth(vector<unique_ptr<Animal>>& animals) override {
        if (gender == Gender::FEMALE && ageInMonths % 6 == 0) {
            Gender newbornGender = (rand() % 2 == 0) ? Gender::MALE : Gender::FEMALE;
            animals.push_back(make_unique<Fish>(getType(), getName(), newbornGender, 0));
        }
    }
};

int main() {
    srand((unsigned int)time(0));
    vector<unique_ptr<Animal>> animals;

    // Add initial animals to the ark
    animals.push_back(make_unique<Mammal>(Type::MAMMAL, "Cat", Gender::FEMALE, 11));
    animals.push_back(make_unique<Mammal>(Type::MAMMAL, "Cat", Gender::MALE, 10));
    animals.push_back(make_unique<Mammal>(Type::MAMMAL, "Dog", Gender::FEMALE, 12));
    animals.push_back(make_unique<Mammal>(Type::MAMMAL, "Cat", Gender::MALE, 9));
    animals.push_back(make_unique<Fish>(Type::FISH, "Goldfish", Gender::FEMALE, 5));
    animals.push_back(make_unique<Fish>(Type::FISH, "Goldfish", Gender::MALE, 5));
    animals.push_back(make_unique<Fish>(Type::FISH, "Shark", Gender::FEMALE, 6));
    animals.push_back(make_unique<Fish>(Type::FISH, "Shark", Gender::MALE, 6));
    animals.push_back(make_unique<Bird>(Type::BIRD, "Eagle", Gender::FEMALE, 8));
    animals.push_back(make_unique<Bird>(Type::BIRD, "Eagle", Gender::MALE, 11));
    animals.push_back(make_unique<Bird>(Type::BIRD, "Parakeet", Gender::FEMALE, 17));
    animals.push_back(make_unique<Bird>(Type::BIRD, "Parakeet", Gender::MALE, 13));

    int months = 0;
    while (true) {
        cout << "nYou have been on the ark for " << months << " months. What would you like to do?" << endl;
        cout << "1 - Let another month pass" << endl;
        cout << "2 - Check inventory" << endl;
        cout << "3 - Quit" << endl;

        int choice;
        cin >> choice;

        if (choice == 1) {
            months++;

            // Age all animals by one month and let them give birth
            for (auto& animal : animals) {
                animal->ageOneMonth();
                animal->giveBirth(animals);
            }
        }
        else if (choice == 2) {
            // Display inventory
            cout << "nInventory:" << endl;
            int count = 1;
            for (const auto& animal : animals) {
                cout << "Animal #" << count++ << ": ";
                animal->identifyAnimal();
            }
        }
        else if (choice == 3) {
            // Clean up memory
            animals.clear();
            break;
        }
    }

    return 0;
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật