C++第6章 数组 指针和字符串.ppt

运行结果: s1 is DEF Please enter s2: pqrst length of s2: 5 s1 = ABC“ returns false DEF = s1 returns true s2 = s2 + s1: pqrstDEF length of s2: 8 * * * * * * ***********2011/04/26 * * * * * * * * * * * * * * * * * * * ****************2011/04/19 * * * * * * * * * * * * * * 6.3 动态内存分配 动态申请内存操作符 new new 类型名T(初始化参数列表) 功能:在程序执行期间,申请用于存放T类型对象的内存空间,并依初值列表赋以初值。 结果值:成功:T类型的指针,指向新分配的内存;失败:抛出异常。 * 6.3 动态内存分配 释放内存操作符delete delete 指针p 功能:释放指针p所指向的内存。p必须是new操作的返回值。 例6-16 动态创建对象举例 * #include iostream using namespace std; class Point { public: Point() : x(0), y(0) { coutDefault Constructor called.endl; }

文档评论(0)

1亿VIP精品文档

相关文档