0
在這個片段中,矢量<bool>沒有可行的重載 '='
void Graph::dfs(int s) const {
m_Marked[s] = true;
// ...
}
其中std::vector<bool> m_Marked;
我從編譯器看到,
../Algorithms/graph.cpp:54:17: error: no viable overloaded '='
m_Marked[s] = true;
~~~~~~~~~~~^~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__bit_reference:155:28: note: candidate function not viable: no known conversion from 'bool' to 'const std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > >' for 1st argument
__bit_const_reference& operator=(const __bit_const_reference& __x);
完全不知道他的問題是什麼,這似乎很基本?
TIA
從對象方法中刪除'const'。 或者,但不建議,將'm_Marked'聲明爲'mutable'。 –