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

📄 li8.cpp

📁 一些关于软件质量保证与测试的资料
💻 CPP
字号:
// li8.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <string.h>

class base
{
public:
	char *p;
	base()
	{
		p = new char[strlen("default value")+1];
		strcpy(p, "default value");
	}

	base &operator = (const base& a)
	{
		if (&a==this) 
			return *this;
		delete []p;
		p = new char[strlen(a.p)+1];
		strcpy(p, a.p);
		return *this;
	}


	void setp(char *s)
	{
		p = new char[strlen(s)+1];
		strcpy(p,s);
	}
	~base()
	{
		if(p)
		{
			delete[] p;
			p=NULL;
		}
	}
};


int main(int argc, char* argv[])
{
	base a,b;
	a.setp("aaaa");
	b = a;
	return 0;
}

⌨️ 快捷键说明

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