'operator =' function is unavailable (HELP!!来者有分!!)
请问下面的程序为什么会引起VC编译器C2582的错误,
说找不到拷贝构造函数,请问该如何解决?不尽感激!
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
using namespace std;
struct CDir
{
int ID;
string Name;
int ParentID;
/* CDir() {}
CDir(const CDir & Dir) {
ID = Dir.ID;
Name = Dir.Name;
ParentID = Dir.ParentID;
}
CDir & operator =(const CDir & Dir) {
ID = Dir.ID;
Name = Dir.Name;
ParentID = Dir.ParentID;
return *this;
}*/ // 加上这段代码也没用:(
};
bool IDEqualsN(pair<int, CDir> elem, int n)
{
return elem.second.ID == n;
}
int main()
{
int i;
map<int, CDir> CDirs;
for (i = 0; i < 10; i++)
{
CDir CDir;
CDir.ID = i;
CDir.Name = "hello";
CDir.ParentID = 0;
CDirs[i] = CDir;
}
CDirs.erase(
remove_if(CDirs.begin(), CDirs.end(), bind2nd(ptr_fun(IDEqualsN), 3)),
CDirs.end());
return 0;
}