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

📄 06_03.cpp

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

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

class text{
	char _content[50];
public:
	text(char* pstr){
		strcpy(_content, pstr);
		cout << "construct: " << _content << endl;
	}

	text(const text& t) {
		strcpy(_content, t._content);
		cout << "copy construct: " << _content << endl;
	}

	~text()	{	
		cout << "destroy: " << _content << endl;
	}

	void print(){	
		cout << _content << endl; 
	}

	friend text catenate(text str1, text str2);
};

text catenate(text str1, text str2)
{
	text str("");
	strcpy(str._content, str1._content);
	strcat(str._content, str2._content);
	return str;
}

void f()
{
	text str1(" hello");
	text str2(" world");
	catenate(str1, str2).print();
}

int main(int argc, char* argv[])
{
	f();
	getch();
	return 0;
}

⌨️ 快捷键说明

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