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

node.js - How do I prevent MongoDB replica set from querying the primary? -

c# - Randomly pick a specific int from a 2D Array -

php - Angularjs http.delete is not working after deploying project on server -