构造函数和析构函数的使用
来源:互联网 发布:黄牛抢票软件个人版 编辑:程序博客网 时间:2024/06/16 00:15
#include "iostream"#include "string"class CVector{ std::string *ptr; public: //Default constructor // 默认构造函数 CVector(){ ptr = new std::string; } //Constructor with parameters //带有一个参数的构造函数 CVector(std::string s):ptr(new std::string(s)){} // Deconstructor ~CVector(){ //析构函数 std::cout << content() << std::endl; std::cout << "release me" << std::endl; delete ptr; } const std::string & content(){return *ptr;}};int main(){ CVector ca; CVector cb("abc");}output:
abc
release me
release me
0 0
- 构造函数和析构函数的使用原因
- 构造函数和析构函数的使用
- string类的构造函数,析构函数,拷贝构造函数和赋值构造函数
- 构造函数和析构函数的构造规则
- C++之析构函数/拷贝构造函数/拷贝赋值函数的概念和使用
- String 的构造函数、析构函数和赋值函数
- string的构造函数,析构函数和赋值函数
- 构造函数、析构函数和函数的重载
- String的构造函数,拷贝构造函数、析构函数和赋值函数
- string类的构造函数,拷贝构造函数,析构函数和赋值函数
- String类的构造函数,析构函数,拷贝构造函数和赋值函数
- string类的构造函数,拷贝构造函数,析构函数和赋值函数
- 编写类String的构造函数、拷贝构造函数、析构函数和赋值函数
- string类的构造函数、析构函数、拷贝构造函数和赋值函数
- 编写类String 的构造函数、拷贝构造函数、析构函数和赋值函数
- 写String类的普通构造函数,析构函数,拷贝构造函数和赋值函数
- C++构造函数和拷贝构造函数等的使用
- 构造函数,拷贝构造函数和析构函数
- python 使用pip 与python path
- jsp页面动态获取时间
- 2012年5月SAT香港真题解析
- 一些sql面试题
- 输入url到页面返回的全过程
- 构造函数和析构函数的使用
- Project Euler :Problem 54 Poker hands
- 网页中引用优酷播放器并使其被遮罩层遮住
- Android自定义消息推送
- iOS开发笔记--多手势事件
- 关于UGUI RectTransform的几个参数的获取和修改(待补充)
- linux c编程中调用 shell 命令
- mongodb aggregate 级联查询
- Hibernate annotation配置方式的MappedBy使用详解