### Backtrack recursion

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

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657`` ``````#ifndef BACKTRACK_HPP_INCLUDED #define BACKTRACK_HPP_INCLUDED #include #include "Map.hpp" using namespace std; class Backtrack { public: vector Search(Map Mmap, int nColors); }; vector Backtrack::Search(Map Mmap, int nColors) { vector answer; //picks an uncolored region string uncolored_region; vector 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 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 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.