⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 05_03.cpp

📁 一些C++的课件和实验源代码
💻 CPP
字号:
// 05_03.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;

class Text {
	char* pContent;
public:
	Text() { pContent = NULL; }	// 构造函数,初始化成员
	~Text() {	// 析构函数,释放资源
		if (pContent != NULL) delete pContent;
	}
	void SetContent(char* str) {	// 设置文本内容
		strcpy(pContent, str); 
	}
	void GetBuffer(int len) {	// 重新分配存储空间
		pContent = new char[len];
		strcpy(pContent, "");
	}
	void Print() { cout << pContent << endl; }	// 输出文本
};

int main(int argc, char* argv[])
{
	Text t;
	t.GetBuffer(10);
	t.SetContent("Hello");

	// ...

	t.SetContent("Hello World!");
	t.Print();

	getch();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -