error: default argument given for parameter 2 of ..

I am not a professional C++ programmer and I apologize in advance if the question seems obvious. I use [this partially observable Markov Decision solver][1] for my problem which I coded based on the examples they provided
In my starmaze.h I have

1
2
3
4
5
6
7
8
9
10
11
12
class StarMazeProblem : public DSPOMDP,
     public MDP,
     public StateIndexer,
     public StatePolicy  {
public
     ParticleUpperBound* CreateParticleUpperBound(std::string name = "DEFAULT") const;//?
      ScenarioUpperBound* CreateScenarioUpperBound(std::string name = "DEFAULT",
              std::string particle_bound_name = "DEFAULT") const;

      ScenarioLowerBound* CreateScenarioLowerBound(std::string name = "DEFAULT",
              std::string particle_bound_name = "DEFAULT") const;
 }


In my starmaze.cpp script I defined these functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
ScenarioUpperBound* StarMazeProblem::CreateScenarioUpperBound(string name,
        string particle_bound_name) const {
        ScenarioUpperBound* bound = NULL;
        if (name == "TRIVIAL" || name == "DEFAULT") {
            bound = new TrivialParticleUpperBound(this);
        } else if (name == "LOOKAHEAD") {
            return new LookaheadUpperBound(this, *this,
                 CreateParticleUpperBound(particle_bound_name));

        } else if (name == "MDP") {
            return new MDPUpperBound(this, *this);
        } else {
            cerr << "Unsupported base upper bound: " << name << endl;
            exit(0);
        }
        return bound;
}
ScenarioLowerBound* StarMazeProblem::CreateScenarioLowerBound(string name,
                                     string particle_bound_name="DEFAULT") const {
        const DSPOMDP* model = this;
	    const StateIndexer* indexer = this;
	    const StatePolicy* policy = this;                                 
        ScenarioLowerBound* bound = NULL;
        if (name == "TRIVIAL" ) {
            bound = new TrivialParticleLowerBound(this);
        } else if (name == "RANDOM") {
            bound = new RandomPolicy(this,
                                     CreateParticleLowerBound(particle_bound_name));
        } else if (name == "MODE" || name == "DEFAULT") {
		    ComputeDefaultActions("MDP");
		     bound = new ModeStatePolicy(model, *indexer, *policy,
			              CreateParticleLowerBound(particle_bound_name));                             
        } else if (name == "CENTER") {
            bound = new BlindPolicy(this, CENTER,
                                    CreateParticleLowerBound(particle_bound_name));

        } else if (name == "OPTIMAL") {
            bound = new OptimalStarMazePolicy(this,
                                              CreateParticleLowerBound(particle_bound_name));
        } else {
            cerr << "Unsupported scenario lower bound: " << name << endl;
            exit(1);
        }
        return bound;
}

the error message is as following

1
2
3
4
5
6
7
8
src/starmaze.cpp:397:76: error: default argument given for parameter 2 of 'despot::ScenarioLowerBound* despot::StarMazeProblem::CreateScenarioLowerBound(std::__cxx11::string, std::__cxx11::string) const' [-fpermissive]
                                      string particle_bound_name="DEFAULT") const {
                                                                            ^~~~~
In file included from src/starmaze.cpp:1:0:
src/starmaze.h:101:27: note: previous specification in 'virtual despot::ScenarioLowerBound* despot::StarMazeProblem::CreateScenarioLowerBound(std::__cxx11::string, std::__cxx11::string) const' here
       ScenarioLowerBound* CreateScenarioLowerBound(std::string name = "DEFAULT",
                           ^~~~~~~~~~~~~~~~~~~~~~~~
src/starmaze.cpp: In member function 'virtual bool despot::StarMazeProblem::Step(despot::State&, double, despot::ACT_TYPE, double&, despot::OBS_TYPE&) const':

I appreciate if someone explain what I should modify to make my code works and the error gets fixed.
Thanks

[1]https://github.com/AdaCompNUS/despot/blob/API_redesign/examples/cpp_models/
Last edited on
Remove the default argument from the definition. It's enough to have it in the declaration.
Topic archived. No new replies allowed.