Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 1 decade ago

請問這個C++類別的用途

這是別人程式中的一個類別,一直不太懂它的用途

class RTPMemoryManager

{

public:

RTPMemoryManager() { }

virtual ~RTPMemoryManager(){ }

/** Called to allocate \c numbytes of memory.*/

virtual void *AllocateBuffer(size_t numbytes, int memtype) = 0;

/** Frees the previously allocated memory block \c buffer */

virtual void FreeBuffer(void *buffer) = 0;

};

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    class RTPMemoryManager

    {

    public:

    RTPMemoryManager() { } //class建構式

    virtual ~RTPMemoryManager(){ } //class解構式

    /*---------------------------------------------------

    *這副程式是跟系統取得一塊記憶體Buffer,返回一個

    *void的指標(記憶體指標)

    */

    /** Called to allocate \c numbytes of memory.*/

    virtual void *AllocateBuffer(size_t numbytes, int memtype) = 0;

    /*---------------------------------------------------

    *釋放記憶體,將allocate的記憶體釋放

    */

    /** Frees the previously allocated memory block \c buffer */

    virtual void FreeBuffer(void *buffer) = 0;

    };

    由於使用virtual function,所以class裡面可能沒有此function的主體

    • Login to reply the answers
Still have questions? Get your answers by asking now.