dimanche 29 novembre 2015

i got error C2027 and error C2227

There are some errors in functions Call::NewCall,Call::FreeCall

This is my code:

    class ObjectPool :public CriticalSection //
{
    T * pool = nullptr;
    unsigned __int32 size;
    __int64 next_free;
    std::vector<T *>free_objects;
public:
    ObjectPool(unsigned __int32 _size) :size(_size), next_free(size - 1);   
    ~ObjectPool();
    T * GetUnusedObject();
    void FreeObject(T * obj_to_free);
};

struct Call
{
    IX * ix;
    ...
        Call(IX * _ix) :ix(_ix){...}
    static Call * NewCall(IX * _ix)
    {
        Call * new_call = _ix->call_pool->GetUnusedObject();
        new_call->InitializeCall(_ix);
        return new_call;
    }
    static void FreeCall(Call * call_to_free)
    {
        call_to_free->ix->call_pool->FreeObject(call_to_free);
    }
};
class IX
{
    ...
public:
    ObjectPool<Call> * call_pool;
    ObjectPool<Session> * session_pool;
    IX()
    {
        call_pool = new ObjectPool<Call>(calls_pool_size);
        session_pool = new ObjectPool<Session>(calls_pool_size);
    }
    ~IX()
    {
        delete call_pool;
        delete session_pool;
    }

Errors: see declaration of 'IX'

error C2227: left of '->call_pool' must point to class/struct/union/generic type

error C2227: left of '->GetUnusedObject' must point to class/struct/union/generic type

error C2027: use of undefined type 'IX'

see declaration of 'IX'

Thanks a lot;

Aucun commentaire:

Enregistrer un commentaire