minimize DFA c++ code has error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suliman11
    New Member
    • Dec 2017
    • 1

    minimize DFA c++ code has error

    hello

    I have a problem In this code


    //Function to minimize DFA
    pair<int,vector <string tuple<int,int,b ool>> > minimize_dfa(ve ctor<dst) {
    cout<<dfa.size( )<<endl;
    vector<int> grp(dfa.size()) ; /// Group number for states
    vector<vector<i nt> > part(2, vector<int>()); /// Partition for groups

    /// Initializing the groups
    int part[0],.push_back(0);
    for(int i=1; i<(int)grp.size (); i++) {
    if(dfa[i].f==dfa[0].f) {
    grp[i]=0;
    part[0].push_back(i);
    } else {
    grp[i]=1;
    part[1].push_back(i);
    }
    }

    if(!part[1].size()) part.erase(part .end());


    in the first line this message will appear
    ([Error] template argument 1 is invalid)

    does any one know about this situation ?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Your function template minimize_dfa has an argument of vector<dst.

    What is vector<dst ?? There's a missing > and an argument name.

    Did you mean vector<dst> arg1 ??

    There's also a typecast of grp.size() to an int. Anytime you cast in C++ it's an error unless you are interfacing with old-style C code. In this case vector::size returns a size_type, not an int.

    You should be using iterators with vectors.

    Comment

    Working...