I have class following code
class Info {
    public:
        inline void append(int i) { var1.push_back(i); }
    private:
        std::list<int> var1; 
};
class Key {
    public:
        int getId() {return id};
    private:
        int id;
};
class Base {
    public:
        void& getMap() { return myMap;} 
    protected:
        map<Key*,Info*> myMap;
};
class B {
    public:
        void check(bool val,map<Key*,Info*>* = NULL) {
            // while processing I get key* as key1
            Key* key1;
            Info* info = new Info;
            info->append(1000);
            myMap.insert(std::pair<Key*,Info*>(key1,info));
        }
};
class Derived : public Base {
    public:
        void func() {
           // since Derived is subclass of Class Base so we access the myMap
           bobject.check(true,&myMap);
        }
    private:
        B bobject;
};
class Client {
  private:
      Base b_report;
  public:
     void client_func() {
         map<Key*,Info*> myMapClient = b_report->getMap();
         // will be using myMapClient;
     } 
};
Three questions
- is there any problem in this code. can we pass pointer of one of member variable to function of other class object
- How to clear the myMap of class Base
- when to clear the myMap of class Base
 
     
    