Backtrack recursion

Hello, I have this code that needs to be recursive, but can't seem to get it to work:

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
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef BACKTRACK_HPP_INCLUDED
#define BACKTRACK_HPP_INCLUDED

#include<vector>

#include "Map.hpp"

using namespace std;

class Backtrack
{
    public:
        vector<int> Search(Map Mmap, int nColors);
};

vector<int> Backtrack::Search(Map Mmap, int nColors)
{
    vector<int> answer;
	//picks an uncolored region
    string uncolored_region;
    vector<int> colored_regions = Mmap.Cregions();
    int region_index;
    for(int r = 0; r < colored_regions.size(); r++)
    {
        if (colored_regions.at(r) == 0)
            region_index = r;
            break;
    }
    vector<string> regions = Mmap.getRegions();
    uncolored_region = regions[region_index];

    //loops over all possible colors
    for(int i = 0; i < regions.size(); i++)
    {
        for(int j = 1; j <= nColors; j++)
        //color uncolor region with color i
        Mmap.changeColor(j, i);

        //test if there are any conflicts
        int conflicts = Mmap.countConflicts();

        //if so continue loop
        if(conflicts != 0)
            continue;
		//if not call Backtrack recursively
        else
        {
            answer = Backtrack(Mmap, nColors);
        }
    }

    //return failure
    return vector<int> fail.push_back(-1);
}

#endif // BACKTRACK_HPP_INCLUDED


This is the error I get:

Backtrack.hpp|58|error: no matching function for call to 'Backtrack::Backtrack(Map&, int&)'|


How do I set it up to be recursive?
Last edited on
What is the meaning of the call on line 48? Did you intend it to be Search(Mmap,nColors)?
*looks at code for a second*...that might be the reason why its giving me that error.

But still, I'm not too familiar with this recursion if anyone would help in understanding it.
Last edited on
Topic archived. No new replies allowed.