As it turns out I need to point to a class variable from a certain function, but the only way this is possible is by pointing to a pointer in another function that points to a class in my main function. I know this may be a newbie question but how is this done, exactly? or is it even possible?
#include <iostream>
class myclass
{
public: //*** I know you meant this to be public
int myvar;
}
void firstfunc(myclass * myclass1);
void secondfunc(myclass * myclass1); //just a pointer not a pointer to pointer
int main()
{
myclass myclass1;
firstfunc(&myclass1);
return 0;
}
void firstfunc(myclass * myclass1)
{
secondfunc(myclass1); //pass the pointer along to the second function
return;
}
void secondfunc(myclass * myclass1) //(got rid of that semi-colon typo) - and just a pointer to myclass not a pointer to pointer
{
std::cout << myclass1->myvar;
return;
}