64,646
社区成员
发帖
与我相关
我的任务
分享
//你直接在类中写
void Show(int iCount){}
//就可以了啊,或者,你把内联函数拷到头文件中
inline void TIntArray::Show(int iCount)
{
}
//可以,你把它拷到头文件中不就是类外定义了吗,在类里的叫声明
inline void TIntArray::Show(int iCount)
{
}
#ifndef ARRAY_H
#define ARRAY_H
你的代码
#endndef //ARRAY_H
#ifndef ARRAY_H
#define ARRAY_H
你的代码
#endndef //ARRAY_H
//IntArray.h
class TIntArray
{
public:
//缺省构造函数
TIntArray(int iCount = DefaultSize);
TIntArray(int *pOriginalArray,int iCount);
//拷贝构造函数
TIntArray(TIntArray &IntArray);
void Show(int iCount);
protected:
private:
const static int DefaultSize = 512;
int iCount;
int *pArray;
};
//IntArray.cpp
#include "IntArray.h"
void TIntArray::Show(int iCount)
{
}
//缺省构造函数
inline TIntArray::TIntArray(int iCount)
{
pArray = new int[iCount];
if (pArray)
{
while (iCount > 0)
{
pArray[iCount - 1] = 0;
}
}
else
{
WarnUser("无法分配内存");
}
}