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

Apache NiFi ExecuteScript: Groovy script to replace Json values via a mapping file -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -