c++ - Returning other classes variables with function and declaration order -


im trying c++ class function can return other classes values. code works if class defined first have more code dont want mangle around. figured need somekind of forward declaration class a.

what kind of forward declaration need work? code in 1 file. problem dissapear if split classes multiple files , include them project or make difference vc++ compiler?

semi pseudo code below.

      // forward declaration     class a;      // class deifinitions     class b {     private:         int testvalue;     public:         void settestvalue(a &aobj);     }      void b::settestvalue(a &aobj) {         testvalue = aobj.settestvalue();     }       class {     private:         int test = 10;     public:         int testvalue();     };      int a::testvalue() {         return test;     }       // mainloop       aobj;     b bobj;      bobj.settestvalue (aobj);  

just put defination of b's member-function after a's class definition.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo