0

I'm trying to implement a trie data structure in order to include autocomplete functionality in a database query syncing application I'm testing out. I'm getting an error here that I don't understand. Anyone know what the problem is?

#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <set>

using namespace std;

class Trie {
    public:
        map<char, Trie> children;
        string value;
        bool flag;

        Trie(const string &);
        void add(char);
        string find(const string &);
        void insert(const string &);
        vector<string> all_prefixes();
        vector<string> autocomplete(const string &);
};

Trie::Trie(const string &val="") {
    value = val;
    flag = false;
}

Error:

In file included from FILEIO.cpp:7:
./trie.h:23:26: error: addition of default argument on redeclaration makes this constructor a default constructor
Trie::Trie(const string &val="") {
                         ^   ~~
./trie.h:15:9: note: previous declaration is here
        Trie(const string &);
        ^
1 error generated.
Austin
  • 6,921
  • 12
  • 73
  • 138

0 Answers0