0

Error in TcpClient.cpp on line return m_ctx; in method getConnection: Use of undeclared identifier 'm_ctx'

Initable.h

#ifndef __L2P__Initable__
#define __L2P__Initable__

#include <iostream>

namespace l2 {

    namespace utils {

        template <typename CTX>
        class Initable {
        protected:
            CTX m_ctx;
        public:
            void init(CTX ctx);
        };

    }
}


#endif /* defined(__L2P__Creatable__) */

TcpClient.h

#ifndef __L2P__TcpClient__
#define __L2P__TcpClient__

#include <iostream>
#include "../utils/Initable.h"
#include "TcpConnection.h"

namespace l2 {

    namespace net {

        template <typename CONN>
        class TcpClient : public utils::Initable<CONN *> {
        public:
            CONN * getConnection();
            virtual void init(CONN * ctx);
        };

    }
}


#endif /* defined(__L2P__TcpClient__) */

TcpClient.cpp

#include "TcpClient.h"

namespace l2 {

    namespace net {

        template <typename CONN>
        CONN * TcpClient<CONN>::getConnection() {
            return m_ctx;
        }

        template <typename CONN>
        void TcpClient<CONN>::init(CONN * ctx) {
            utils::Initable<CONN *>::init(ctx);
            ctx->setClient(this);
        }

    }
}
Krab
  • 6,526
  • 6
  • 41
  • 78
  • 1
    Since `m_ctx` exists in a templated base class you need to provide a well qualified name such as `Initable::m_ctx` – Captain Obvlious Mar 19 '14 at 20:52
  • @CaptainObvlious: ty, post it as answer so i can accept it – Krab Mar 19 '14 at 20:55
  • I would except there's already a more than suitable answer that more than addresses your question. I suggest upvoting which ever answer in the duplicate post that helps you the most. – Captain Obvlious Mar 19 '14 at 21:46

0 Answers0