I wrote down an example code to try to replicate the error I am getting in a school project about the scope of an object:
In file: classTest.cpp
#include "headerone.h"
#include "headertwo.h"
#include <iostream>
using namespace std;
int main() {
    ClassOne* pntrObj1 = new ClassOne;
    ClassTwo* pntrObj2 = new ClassTwo;
    pntrObj1->testClassOne();
    return 0;
}
In file: headerone.h
#ifndef HEADERONE_H
#define HEADERONE_H
#include "headertwo.h"
#include <iostream>
using namespace std;
class ClassOne {
    public:
        void testClassOne() {
            cout << "One Worked\n";
            pntrObj2->testClassTwo();
        }
};
#endif
In file: headertwo.h
#ifndef HEADERTWO_H
#define HEADERTWO_H
#include <iostream>
using namespace std;
class ClassTwo {
    public:
        void testClassTwo() {
            cout << "Two Worked";
        }
};
#endif
To be clear, the error is: pntrObj2 was not declared in this scope. The error comes from the file headerone.h
If I had to guess, I need to somehow pass the reference but I am not sure where to start for that. Any help is appreciated.
 
     
    