celemine1Gig
05-25-2009, 08:58 AM
Hi guys,
I have a problem here that nearly makes me go crazy. I'm sure I'm missing something (something big) and I don't really get it.
Here's the deal:
I have 3 classes (A,B,C).
Each class has a list of members (double values) and some functions to compute new values. Now for some computations, one class needs member-values from another class.
So, our professor told us to use forward declaration and pointers to solve that problem.
I did it like described in the following link and created a pointer in the class B header, to class A.
http://www-subatech.in2p3.fr/~photons/subatech/soft/carnac/CPP-INC-1.shtml
Now I thought that I could get the values from class A's members as follows:
If I have a pointer, just like in the linked example, named "fPtrA", can't I just use that in my class B member function as follows:
B::X = fPtrA->rtrn_member1() + B::Y
The "rtrn_member1()" function really is nothing else than the following simple code:
A::rtrn_member1() const {return member1;};
If I try to use this method, described above, in my class B member function, I immediately get an access violation.
So, where is my huge misunderstanding? Any hints are highly appreciated, as I'm starting to go nuts. :D
Thx in advance!
Ingmar :)
I have a problem here that nearly makes me go crazy. I'm sure I'm missing something (something big) and I don't really get it.
Here's the deal:
I have 3 classes (A,B,C).
Each class has a list of members (double values) and some functions to compute new values. Now for some computations, one class needs member-values from another class.
So, our professor told us to use forward declaration and pointers to solve that problem.
I did it like described in the following link and created a pointer in the class B header, to class A.
http://www-subatech.in2p3.fr/~photons/subatech/soft/carnac/CPP-INC-1.shtml
Now I thought that I could get the values from class A's members as follows:
If I have a pointer, just like in the linked example, named "fPtrA", can't I just use that in my class B member function as follows:
B::X = fPtrA->rtrn_member1() + B::Y
The "rtrn_member1()" function really is nothing else than the following simple code:
A::rtrn_member1() const {return member1;};
If I try to use this method, described above, in my class B member function, I immediately get an access violation.
So, where is my huge misunderstanding? Any hints are highly appreciated, as I'm starting to go nuts. :D
Thx in advance!
Ingmar :)