cpp12.8
来源:互联网 发布:mac 把自己改为管理员 编辑:程序博客网 时间:2024/06/05 04:28
placenew1.cpp
#include<iostream>#include<string>#include<new>using namespace std;const int BUF = 512;class JustTesting{private:string words;int number;public:JustTesting(const string & s = "Just Testing", int n = 0){words = s; number = n; cout << words << "constructed\n";}~JustTesting() { cout << words << "destroyed\n"; }void Show() const { cout << words << ", " << number << endl; }};int main(){char*buffer = new char[BUF];JustTesting*pc1, *pc2;pc1 = new (buffer) JustTesting;pc2 = new JustTesting("Heap1", 20);cout << "Memory block addresses:\n" << "buffer: "<< (void *)buffer << " heap: " << pc2 << endl;cout << "Memory contents:\n";cout << pc1 << ": ";pc1->Show();cout << pc2 << ": ";pc2->Show();JustTesting*pc3, *pc4;pc3 = new(buffer) JustTesting("Bad Idea", 6);pc4 = new JustTesting("Heap2", 10);cout << "Memory contents:\n";cout << pc3 << ": ";pc3->Show();cout << pc4 << ": ";pc4->Show();delete pc2;delete pc4;delete[] buffer;cout << "Done\n";system("pause");return 0;}
0 0
- cpp12.8
- cpp12.4
- cpp12.10
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- 8
- brew install mongo
- javaProject.gradle
- javascript 创建对象——类,继承
- rabbitMQ 命令
- Why L1 norm for sparse models?
- cpp12.8
- POJ 1077 八数码问题
- webappProject.gradle
- Ember 从0到1
- Android中的string资源占位符及Plurals string
- 微信支付出现--3当前页面的URL未注册
- HBase学习笔记 --- hbase-indexer WIKI
- JVM栈
- CentOS6.4下Mysql数据库的安装与配置