c++ - Template function with a forward declared class -


noob question here. have class circular dependency forward declared it. now, i'm planning try out template this.

//in c.h

class c { public:   virtual void getmap(); } 

// in a.h

    class c;     class {     public:        virtual void foo(c *c);      template <class t>             void changeproperty(c *c, string& s) {           void* obj = c->getmap()->at(s); // not compile            // (did not include rest brevity)        }     } 

this fails compile @ line specified stating class c doesn't have function 'getmap()'. can fixed? if so, how?

move definition of changeproperty out of class (so it's not inline) , place somewhere after definition of class c has been seen.

so preprocessed result end like:

class c; class { public:    virtual void foo(c *c);  template <class t>         void changeproperty(c *c, string& s); }  // ...  class c { public:   virtual void getmap(); }  // ...  template <class t>         void a::changeproperty(c *c, string& s)    {       void* obj = c->getmap()->at(s); // compiles       // (did not include rest brevity)    } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -