mardi 20 mars 2018

Access member variables of class inherited from interface

I have created an Interface:

//A.h
#include <map>

class IA
{
     public:
          virtual void getVar() = 0;
          typedef void (int::*get)();
};

//B.h

#include "A.h"

class B : public IA
{
     public:
          virtual void getVar() override
          {
          }
          typedef void (int::*get)();
          std::map <int, get> Fmap;
};

//BFactory.hpp

#include "B.hpp"

 std::unique_ptr<A> create(..);

//B.cpp

Fmap.insert(...);

//BFactory.cpp

std::unique_ptr<A> create(..)
{
     return std::make_unique<B>();
}

//C.cpp
#include "BFactory.hpp"

std::unique_ptr<A> obj = std::move(create(...));

Now how can obj access 'Fmap' variable?

Aucun commentaire:

Enregistrer un commentaire