), например:

я есть массив объектов

Passenger travellers[] = {
    Passenger(nullptr, "Toronto", 2018, 4, 20),
    Passenger("", "Toronto", 2018, 4, 20),
    Passenger("John Smith", nullptr, 2018, 4, 20),
    Passenger("John Smith", "", 2018, 4, 20),
    Passenger("John Smith", "Toronto", 2018, 4, 20), // valid
    Passenger("John Smith", "Toronto", 2028, 4, 20),
    Passenger("John Smith", "Toronto", 2014, 4, 20),
    Passenger("John Smith", "Toronto", 2020, 12, 31), // valid
    Passenger("John Smith", "Toronto", 2018, 40, 20),
    Passenger("John Smith", "Toronto", 2018, 0, 20),
    Passenger("John Smith", "Toronto", 2017, 1, 1), // valid
    Passenger("John Smith", "Toronto", 2018, 4, 0),
    Passenger("John Smith", "Toronto", 2018, 4, 32),
    Passenger(nullptr, nullptr, 0, 0, 0),
    Passenger()
};

и мои конструкторы:

конструктор по умолчанию

Passenger::Passenger() {
    p_name[0] = '\0';
    p_dest[0] = '\0';

    // destination date
    d_yy = 0;
    d_mm = 0;
    d_dd = 0;
}

И мой другой конструктор с параметрами:

Passenger::Passenger(const char *name, const char *destination, int year, int month, int days) {

    if (name != nullptr && destination != nullptr && name[0] != '\0' && destination[0] != '\0') {
        if (year >= 2017 && year <= 2020 && month >= 1 && month <= 12 && days >= 1 && days <= 31) {
            strncpy(p_name, name, 32);
            strncpy(p_dest, destination, 32);
            d_yy = year;
            d_mm = month;
            d_dd = days;
        }
        else 
            Passenger();
    }
    else
        Passenger();
}

Проблема заключается в том, что остальные объекты должны возвращать «недопустимый», но самый первый объект возвращает «действительный», хотя он имеетnullptr стоимость. Кто-нибудь знает, что я делаю не так?

Ответы на вопрос(2)

Ваш ответ на вопрос