myclass.cpp
来自「此文件可以能帮你求体积」· C++ 代码 · 共 57 行
CPP
57 行
// MyClass.cpp: implementation of the MyClass class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyClass.h"
#include <iostream.h>
#include <stdlib.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
MyClass::MyClass( int i )
{
p = new int;
if ( !p )
{
cout << "Allocation error\n";
exit(1);
}
*p = i;
}
MyClass::~MyClass()
{
delete p;
}
#if _SONGK_USE_CP_CTOR_
MyClass::MyClass( const MyClass& obj )
{
if ( p != NULL )
{
delete p;
p = NULL;
}
p = new int;
if (!p)
{
cout << "Allocation error\n";
exit(1);
}
*p = *obj.p;
}
#endif
int GetVal( MyClass obj )
{
return *obj.p;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?