strtype.cpp

来自「本文档含有多个C++程序」· C++ 代码 · 共 37 行

CPP
37
字号
// StrType.cpp: implementation of the StrType class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "StrType.h"
#include <iostream.h>
#include <string.h>
#include <stdlib.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

StrType::StrType( char* ptr )
{
	len = strlen( ptr );
	p = new char[ len + 1 ];
	if ( !p )
	{
		cout << "Allocation error\n";
		exit(1);
	}
}

StrType::~StrType()
{
	cout << "Freeing p\n";
	delete[] p;
}

void StrType::Show()
{
	cout << p << "length:" << len;
	cout << endl;
}

⌨️ 快捷键说明

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