当前位置:   article > 正文

xxxxxx

xxxxxx

typedef struct

{

   int refs;       // reference count

   int count_1fen;

   int count_2fen;

   int count_5fen;

} bank_data_s_type

 

bank_data_s_type* PiggyBank_New( )

{

bank_data_s_type *pNew = MALLOC(sizeof(bank_data_s_type));

   if (pNew != NULL)

      MEMSET(pNew, 0x00, sizeof(bank_data_s_type));

   PiggyBank_AddRefs(pNew);

   return pNew;

}

 

static void PiggyBank_Free(bank_data_s_type **ppData)

{

   if (NULL == ppData)

      return;

   FREE(*ppData);

   *ppData = NULL;

}

 

int PiggyBank_AddRefs(bank_data_s_type *pData)

{

   return pData->refs++;

}

 

int PiggyBank_Release(bank_data_s_type *pData)

{

   if (--pData->refs > 0)

      return pData->refs;

   PiggyBank_Free(&pData);

   return 0;

}

 

void PiggyBank_Input(bank_data_s_type *pData, int type)

{

   … …

}

 

void PiggyBank_Output(bank_data_s_type *pData, int type)

{

   … …

}

 

int PiggyBank_GetTotal(bank_data_s_type *pData, int type)

{

  … …

}

 

///

 

enum

{

COIN_TYPE_NONE,

   COIN_TYPE_1FEN,

   COIN_TYPE_2FEN,

   COIN_TYPE_5FEN

};

 

typedef struct PiggyBank PiggyBank;

 

PiggyBank* PiggyBank_New( );

int PiggyBank_AddRefs(PiggyBank *pPiggyBank);

int PiggyBank_Release(PiggyBank *pPiggyBank);

void PiggyBank_Input(PiggyBank *pPiggyBank, int type);

void PiggyBank_Output(PiggyBank *pPiggyBank, int type);

int PiggyBank_GetTotal(PiggyBank *pPiggyBank, int type);

   

储蓄罐封装形式四:PiggyBank.c

struct PiggyBank

{

   int refs;       // reference count

   int count_1fen;

   int count_2fen;

   int count_5fen;

};

 

PiggyBank* PiggyBank_New( )

{

PiggyBank *pNew = MALLOC(sizeof(PiggyBank));

   if (pNew != NULL)

      MEMSET(pNew, 0x00, sizeof(PiggyBank));

   PiggyBank_AddRefs(pNew);

   return pNew;

}

 

static void PiggyBank_Free(PiggyBank **ppPiggyBank)

{

   … …

}

 

int PiggyBank_AddRefs(PiggyBank *pPiggyBank)

{

   … …

}

 

int PiggyBank_Release(PiggyBank *pPiggyBank)

{

   … …

}

 

void PiggyBank_Input(PiggyBank *pPiggyBank, int type)

{

   … …

}

void PiggyBank_Output(PiggyBank *pPiggyBank, int type)

{

   … …

}

 

int PiggyBank_GetTotal(PiggyBank *pPiggyBank, int type)

{

  … …

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/71876
推荐阅读
相关标签
  

闽ICP备14008679号