When I try to compile my code, I get this error:
------ Build started: Project: SUD, Configuration: Debug Win32 ------
Compiling...
baseent.cpp
c:\program files\microsoft visual studio 9.0\vc\include\xmemory(52) : error C2558: class 'BaseEnt' : no copy constructor available or copy constructor is declared 'explicit'
c:\program files\microsoft visual studio 9.0\vc\include\xmemory(155) : see reference to function template instantiation 'void std::_Construct<BaseEnt,_Ty>(_T1 *,const _T2 &)' being compiled
with
[
_Ty=BaseEnt,
_T1=BaseEnt,
_T2=BaseEnt
]
c:\program files\microsoft visual studio 9.0\vc\include\xmemory(154) : while compiling class template member function 'void std::allocator<_Ty>::construct(BaseEnt *,const _Ty &)'
with
[
_Ty=BaseEnt
]
c:\program files\microsoft visual studio 9.0\vc\include\vector(429) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
with
[
_Ty=BaseEnt
]
c:\program files\microsoft visual studio 9.0\vc\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
with
[
_Ty=BaseEnt,
_Alloc=std::allocator<BaseEnt>
]
c:\documents and settings\tom\my documents\visual studio 2008\projects\sud\sud\baseent.h(25) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=BaseEnt
]
Generating Code...
Compiling...
main.cpp
Generating Code...
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\SUD\SUD\Debug\BuildLog.htm"
SUD - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I clicked on it, and it pointed me to this line of code: extern std::vector<BaseEnt> entities;
This is where BaseEnt is defined:
class BaseEnt{
int id;
static int count;
std::string hashcode;
std::string name;
public:
BaseEnt();
BaseEnt(std::string name);
BaseEnt(BaseEnt &other);
~BaseEnt();
int GetID();
std::string GetHashCode();
std::string GetClassName();
int GetCount();
};
This is where it's member definitions are:
int BaseEnt::count = 1;
std::vector<BaseEnt> entities(;
BaseEnt::BaseEnt()
:id(count), name("unassigned"), hashcode(HashCode())
{
name += HashCode();
entities[id] = *this;
count++;
}
BaseEnt::BaseEnt(std::string classname)
:id(count), name(classname), hashcode(HashCode())
{
entities[id] = *this;
count++;
}
BaseEnt::BaseEnt(BaseEnt &other)
:id(other.GetID()), name(other.GetClassName()), hashcode(other.GetHashCode())
{
entities[id] = *this;
count++;
}
BaseEnt::~BaseEnt()
{
count--;
}
std::string BaseEnt::GetClassName()
{ return name; }
int BaseEnt::GetCount()
{ return BaseEnt::count; }
std::string BaseEnt::GetHashCode()
{ return hashcode; }
int BaseEnt::GetID()
{ return id; }
I have never seen this error, and I can't figure out what it means, because I've got a copy constructor in my class(line 9).
And help will be appreciated.