J
Jurek Dabrowski
hi all,
I am trying to access a public variable "m_bHaveAnswer" declared in class
foo from class foo2. Class foo2 declares a pointer to the class foo. This
compiles fine, but when I try to step through the code in debug mode,
"m_bHaveAnswer" cannot be evaluated from within class foo2 via the pointer
to class foo. Any ideas ?
thanks,
jurek
file foo1.h
class foo
{
public:
foo();
~foo();
public:
bool m_bHaveAnswer;
};
file foo2.h
class foo2
{
public:
foo2();
~foo2();
public:
foo* fooPtr;
};
file foo1.cpp
#include "foo11.h"
using namespace std;
foo::foo()
{
cout << "foo constuctor called\n";
}
foo::~foo()
{
cout << "foo destuctor called\n";
}
file foo2.cpp
#include "foo2.h"
using namespace std;
foo2::foo2()
{
cout << "foo constuctor called\n";
}
foo2::~foo2()
{
cout << "foo destuctor called\n";
}
file Class_Test.cpp
using namespace std;
#include "foo1.h"
#include "foo2.h"
int _tmain(int argc, _TCHAR* argv[])
{
foo2 f2;
f2.fooPtr->m_bHaveAnswer = 0;
cout << "f2.fooPtr->m_bHaveAnswer = " << f2.fooPtr->m_bHaveAnswer << endl;
return 0;
}
I am trying to access a public variable "m_bHaveAnswer" declared in class
foo from class foo2. Class foo2 declares a pointer to the class foo. This
compiles fine, but when I try to step through the code in debug mode,
"m_bHaveAnswer" cannot be evaluated from within class foo2 via the pointer
to class foo. Any ideas ?
thanks,
jurek
file foo1.h
class foo
{
public:
foo();
~foo();
public:
bool m_bHaveAnswer;
};
file foo2.h
class foo2
{
public:
foo2();
~foo2();
public:
foo* fooPtr;
};
file foo1.cpp
#include "foo11.h"
using namespace std;
foo::foo()
{
cout << "foo constuctor called\n";
}
foo::~foo()
{
cout << "foo destuctor called\n";
}
file foo2.cpp
#include "foo2.h"
using namespace std;
foo2::foo2()
{
cout << "foo constuctor called\n";
}
foo2::~foo2()
{
cout << "foo destuctor called\n";
}
file Class_Test.cpp
using namespace std;
#include "foo1.h"
#include "foo2.h"
int _tmain(int argc, _TCHAR* argv[])
{
foo2 f2;
f2.fooPtr->m_bHaveAnswer = 0;
cout << "f2.fooPtr->m_bHaveAnswer = " << f2.fooPtr->m_bHaveAnswer << endl;
return 0;
}