作者在 2014-04-26 11:15:22 发布以下内容
#include <iostream>
#include <string>
using namespace std;
class Cbook
{
private:
char *m_pczName;
int m_nPages;
int m_nEdition;
public:
void GetBookName(char *pName);
int GetTotalPages();
int GetBookEdition();
private:
void SetBookName(char *pName);
void SetTotalPages(int nPages);
void SetBookEdition(int nEdition);
public:
Cbook();
};
void Cbook::GetBookName(char *pName)
{
strcpy(pName,m_pczName);
}
int Cbook::GetBookEdition()
{
return m_nEdition;
}
void Cbook::SetBookName(char *pName)
{
if(m_pczName!=0)
delete[] m_pczName;
m_pczName=new char[strlen(pName)+1];
strcpy(m_pczName,pName);
}
void Cbook::SetTotalPages(int nPages)
{
m_nPages=nPages;
}
void Cbook::SetBookEdition(int nEdition)
{
m_nEdition=nEdition;
}
int main()
{
Cbook op1;
int i;
i=op1.GetBookEdition();
cout<<i<<endl;
return 0;
}//调试没问题,运行的时候出错了,求指点!!!!