mardi 2 mai 2017

How to define a nested class and use it

I declared a nested class Element, and I want to use create such object and push into an array that storing Element in my AOSMatrix class. The problem I have is that I don't know what should I use in the function push_back in my void push_back(int i, int j, double val) Here is the rest of my code: #include #include

using namespace std;

class AOSMatrix {
    public:
    AOSMatrix(int M, int N) : iRows(M), jCols(N) {}

    void push_back(int i, int j, double val) {
        assert(i < iRows && i >= 0);
        assert(j < jCols && j >= 0);

        arrayData.push_back(???);
    }

    private:
        class Element {
            public:
                int row, col;
                double val;
        }

        int iRows, jCols;
        vector<Element> arrayData;
}

Aucun commentaire:

Enregistrer un commentaire