mercredi 4 janvier 2023

How do I clear or fix "warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]"?

I'm very new to C++ and am attempting to compile my C++ project, but keep getting held up by the warning "warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]". I've been looking everywhere for a solution and nothing seems to clear these errors. Code is attached below. If anyone knows of a quick way to clear these warnings or modify my code to keep it in compliance, any help would be much appreciated.

Warning is showing on MAX_COURSES, ROSTER_SIZE, and classRosterArray

#pragma once

#include "student.h"

using namespace std;

//class Roster;

class Roster
{
public: // don't initalize
    
    Roster();
    ~Roster();
    void add(string studentID,
        string firstName,
        string lastName,
        string emailAddress,
        int age,
        int daysInCourse1,
        int daysInCourse2,
        int daysInCourse3,
        DegreeProgram degreeprogram);
    void remove(string studentID);
    void printAll();
    void printAverageDaysInCourse(string studentID);
    void printInvalidEmails();
    void printByDegreeProgram(DegreeProgram);
    void printByDegreeProgram();
    string getSID(int studentNo);
    //add accessor;
    //add mutator;

private:
    const int MAX_COURSES = 3;
    const int ROSTER_SIZE = 5;
    // E1 Create an array of pointers, classRosterArray, to hold the data provided in the “studentData Table.”
    Student* classRosterArray[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
};

I'm aware of what the warning is telling me, and I've ensured that my c++ standard is set to C++11.

Aucun commentaire:

Enregistrer un commentaire