HOw to add a vector<string> to a vector<vector<string>> belonging to an object?

Viewed 56

I'm having trouble adding a vector<string> to a vector<vector<string>>. It seems like it should be an easy enough task, but I haven't been able to figure what I'm doing wrong with my implementation.

Here's the source files. The code is roughly laid out like this...

State.h

class State{
    private:
        int stateNum;
        // vector<vector<string>> transitions;
        
        bool isStart = false;
        bool isAccept = false;

    public:
        vector<vector<string>> transitions;
        void addTransition(vector<string> transition);

State.cpp : addTransition

void State::addTransition(vector<string> transition){
    transitions.push_back(transition);
    cout << "pair " << transition[0] << "," << transition[1] << " added" << endl;
}

Main File

getState(stoi(from), stateArr).transitions.push_back(transition);

That's not the only thing in main(), but it's the only thing that's relevant.

When I run the code, none of the transitions get added to the vector in the state. I can't figure out why. I would really appreciate some help.

0 Answers
Related