c++ - how to access a variable in one .cc file from another in omnet++ -
i working on omnet++ project , looking solution following problem. have variable "numsent" in file a.cc , want access file b.cc. simplified code snippet below:
a.cc void a::handlefunc(cmessage *msg) { frame=encapsulate(msg); numsent=frame.getvalue(); } a.h protected: long numsent; public: void setupdate(csmacamac *obj); long getupdate(); b.cc #include a.h void b::updatefunc() { *obj=new a(); obj->setupdate(obj); ev<< "inside updategateway"<<obj->getupdate(); } however not retrieve value in a.cc instead gives default 0 value. tried declaring variable global using extern command. throws error. can suggest needs done.
wiki
Comments
Post a Comment