国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

cpp 12.9

2019-11-11 03:25:39
字體:
來源:轉載
供稿:網友

placenew2.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 address:/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 + sizeof(JustTesting))		JustTesting("Better Idea", 6);	pc4 = new JustTesting("Heap2", 10);	cout << "Memory contemts:/n";	cout << pc3 << ": ";	pc3->Show();	cout << pc4 << ": ";	pc4->Show();	delete pc2;	delete pc4;	pc3->~JustTesting();	pc1->~JustTesting();	delete[] buffer;	cout << "Done/n";		system("pause");	return 0;}


上一篇:專題7-ARM時鐘初始化

下一篇:cpp 12.9

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长春市| 临清市| 泰兴市| 平凉市| 佛山市| 龙川县| 丰镇市| 永新县| 朔州市| 广德县| 萍乡市| 大田县| 仁怀市| 云霄县| 景洪市| 瓦房店市| 泰来县| 武乡县| 涞水县| 赤峰市| 百色市| 满城县| 永清县| 阿克陶县| 江油市| 同心县| 库伦旗| 金沙县| 元氏县| 昭苏县| 镇巴县| 岳普湖县| 田阳县| 获嘉县| 浮山县| 嵊州市| 绥宁县| 西平县| 石棉县| 湖北省| 萨嘎县|