{
public:
// Public methods
//! Empty constructor
Handle(Standard_Transient) ()
: entity(0)
{
}
//! Constructor from pointer to new object指向新对象指针的构造函数
Handle(Standard_Transient) (const Standard_Transient anItem)
: entity ( (Standard_Transient)anItem )
{
BeginScope();
}
//! Copy constructor拷贝构造函数
** Handle(Standard_Transient) (const Handle(Standard_Transient)& aTid)
: entity ( aTid.entity )
{
BeginScope();
} **
//! Destructor
~Handle(Standard_Transient)()
{
EndScope();
}
//! Assignment operator
Handle(Standard_Transient)& operator=(const Handle(Standard_Transient)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
//! Assignment operator
Handle(Standard_Transient)& operator=(const Standard_Transient* anItem)
{
Assign(anItem);
return *this;
}
//! Nullify the handle
void Nullify()
{
EndScope();
}
//! Check for being null
Standard_Boolean IsNull() const
{
return entity == 0;
}
//! Returns pointer to referred object
Standard_Transient* Access()
{
return entity;
}
//! Returns const pointer to referred object
const Standard_Transient* Access() const
{
return entity;
}
//! Cast to pointer to referred object
operator Standard_Transient*()
{
return entity;
}
//! Cast to const pointer to referred object
operator const Standard_Transient*() const
{
return entity;
}
//! Member access operator (note non-const)
Standard_Transient* operator->() const
{
return entity;
}
//! Dereferencing operator
Standard_Transient& operator*()
{
return *entity;
}
//! Const dereferencing operator
const Standard_Transient& operator*() const
{
return *entity;
}
//! Check for equality
int operator==(const Handle(Standard_Transient)& right) const
{
return entity == right.entity;
}
//! Check for equality
int operator==(const Standard_Transient *right) const
{
return entity == right;
}
//! Check for equality
friend bool operator==(const Standard_Transient *left, const Handle(Standard_Transient)& right)
{
return left == right.entity;
}
//! Check for inequality
bool operator!=(const Handle(Standard_Transient)& right) const
{
return entity != right.entity;
}
//! Check for inequality
bool operator!=(const Standard_Transient *right) const
{
return entity != right;
}
//! Check for inequality
friend bool operator!=(const Standard_Transient *left, const Handle(Standard_Transient)& right)
{
return left != right.entity;
}
//! Down casting operator; dummy provided for consistency with other classes
//! (descendants)
static const Handle(Standard_Transient)& DownCast(const Handle(Standard_Transient)& AnObject)
{
return AnObject;
}
//! Dump pointer to a referred object to a stream
Standard_EXPORT void Dump(Standard_OStream& out) const;
protected:
// Protected methods for descendants
//! Returns non-const pointer to referred object
Standard_Transient* ControlAccess() const
{
return entity;
}
//! Assignment
Standard_EXPORT void Assign (const Standard_Transient *anItem);
private:
// Private methods
//! Increment reference counter of referred object
Standard_EXPORT void BeginScope();
//! Decrement reference counter and if 0, destroy referred object
Standard_EXPORT void EndScope();
public:
DEFINE_STANDARD_ALLOC
private:
// Field
Standard_Transient *entity;
};
//! Function in global scope to check handles for equality.函数在全局范围内检查句柄是否相等。
//! Will be used with standard OCCT collections like NCollection_DataMap within NCollection_DefaultHasher当没有为具体类型定义特化时,将与
//! when there are no specialization defined for concrete type. NCollection_DefaultHasher中的标准OCCT集合一起使用,如NCollection_DataMap。
//! Notice that this implementation compares only pointers to objects!注意,这个实现只比较指针和对象!
inline Standard_Boolean IsEqual (const Handle(Standard_Transient)& theFirst,
const Handle(Standard_Transient)& theSecond)
{
return theFirst == theSecond;
}
#ifdef _WIN32
#pragma warning (pop)
#endif
#endif
报错0xC0000005 : 读取位置 0x00000000 时发生访问冲突。
上面的意思就是,你把值付给了不该赋给的变量,或者说你把值付给了不能付给的变量(或者常量)
(1)最简单也最直接的错误可能就是scanf()的问题,我们都知道输入的时候都是scanf("%格式",&变量),那么除了字符串(可要&,可不要)之外,所有的输入都需要&,如果你丢了,在很多编译器上变异的时候是查不出来的,也就是说是没有错的,但是输入数据会差生上述错误,是因为写成scanf("%格式",变量)这种形式了,这样你所输入的变量就不知道会存储到哪里。
(2)空指针赋值的问题。
我们知道如果某一个指针是空的是不能直接给他赋值的,原因是空指针不知道指得什么东西,那么他没有固定的内存,现在你给他赋值,通俗点理解就是他不知道该怎么存,也不知道存在哪,也不会储存,但是现在你有需要让他存储,那么就会出现上述的问题,这时候解决办法就是重新申请空间(用malloc或者new),或者是你尽量避免他成为空指针,或者是当他有成为空指针的可能性时,你就单独讨论。
大概率是出现了空指针。没有判断指针是否为空就进行后续操作导致的错误
嗯,你把文件发过来我看一下
在visual Studio里加载程序pdb符号文件,debug调试,查看代码崩溃堆栈提示信息,进行分析