3.软件业巨无霸(4)
点此返回管理励志系列书籍在线阅读 首页
1.#include
#include
class CBuffer
{
char * m_pBuffer;
int m_size;
publc:
CBuffer()
{
m_pBuffer=NULL;
}
~CBuffer()
{
Free();
}
void Allocte(int size)
{
m_size=size;
m_pBuffer= new char[size];
}
private:
void Free()
{
if(m_pBuffer!=NULL)
{
delete m_pBuffer;
m_pBuffer=NULL;
}
}
public:
void SaveString(const char* pText) const
{
strcpy(m_pBuffer, pText);
char* GetBuffer() const
{
return m_pBuffer;
}
};
void main (int argc, char* argv[])
{
cBuffer buffer1;
buffer1.SaveString(“Microsoft”);
printf(buffer1.GetBuffer());
}
}
找出Allocate, SaveString, main的错误。