Hi Again all,
Please look into my package structure below. I am trying to access a variable of Parser class from callsomemethod() method of a different class. I don't want to pass this through arguments since the function calls many other functions in between and I will have to change many files. Basically I just need a variable t that I can access and update from all the classes.
Please help
parser class{
public:
int t= 0;
};
Exec.cpp
---------
#include "Parser.h"
main()-- HERE IS WHERE MY PROGRAM WILL START
{
Parser pParser;
pParser->t= 1
callsomemethod()
}
someother.cpp
----------
callsomemethod()
{
// CAN WE ACCESS THE pParser->t variable from here without passing it though function
}
Syntactical check : you're creating a stack based Parser object and trying to dereference it like a pointer using the -> operator. Try the '.' operator instead ;)
And pretty much the only way you're going to be able to access that Parser object without passing it as an argument is to make the object global and make it extern.