内容发布更新时间 : 2024/12/25 3:21:11星期一 下面是文章的全部内容请认真阅读。
.
UG二次开发模板
目 录
第一章 技巧规则 ····························································································································· (2) 第二章 函数模板 ····························································································································· (4) 第三章 功能模板 ··························································································································· (11) 第四章 udop····································································································································· (24)
Word专业资料
.
注:连接:Ctrl+单击鼠标左键
第一章 技巧规则
1,存原则:
【规则1】用malloc或new申请存之后,应该立即检查指针值是否为NULL。 防止使用指针值为NULL的存。
【规则2】不要忘记为数组和动态存赋初值。防止将未被初始化的存作为右 值使用。
【规则3】避免数组或指针的下标越界,特别要当心发生“多1”或者“少1” 操作。
【规则4】动态存的申请与释放必须配对,防止存泄漏。
【规则5】用free或delete释放了存之后,立即将指针设置为NULL,防止产 生“野指针”。 2,
Word专业资料
.
数组要么在静态存储区被创建(如全局数组),要么在栈上被创建。数组名对应着(而不是指向)一块存,其地址与容量在生命期保持不变,只有数组的容可以改变。 指针可以随时指向任意类型的存块,它的特征是“可变”,所以我们常用指针来操作动态存。指针远比数组灵活,但也更危险。
注意当数组作为函数的参数进行传递时,该数组自动退化为同类型的指针。
new/delete的功能完全覆盖了malloc/free,为什么C++不把malloc/free淘 汰出局呢?
这是因为C++程序经常要调用C函数,而C程序只能用malloc/free管理动态存。
2,分配空间 double (*point)[3];
point = new double[count][3];
delete[]point;//正确的用法
/*delete point;//错误的用法=delete point[0]*/ 3,
UF_MODL_update();//使用UF_MODL_edit时用来刷新
4 UF_UI_ONT_refresh ();//刷新导航器
Word专业资料