strtype.cpp
来自「大量的C++语言代码,可以快速的学习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 + -
显示快捷键?