Quote:
Originally Posted by
Hlynkacg

as for the rest, I've been reading up on access violations (Yay! Google) and trying to figure out why Martins' AttitudeReference class can call vessel variables without crashing but LEM_AP can't.
Don't take my words about memory access violation for sure it was a pure guess since this as well as memory leaks are two most common errors while dealing with pointers. Also since I've mentioned memory leaks you did remember about deleting autopilot object didn't you ?
Quote:
I found the following lines in the class defthat I think are signifigant but I'm not sure.
Code:
class AttitudeReference {
public:
AttitudeReference (const VESSEL *vessel);
inline const VESSEL *GetVessel() const { return v; }
later on in the class there is
Code:
private:
const VESSEL *v;
If this does what I think it does it assigns the handle "v" to whatever vessel a particular instance of AttitudeReference is assigned to.
No, you're wrong here, the function GetVessel() doesn't do anything to v pointer, it only provides access to it. Look at it's body, there's only one instuction there "return v;" and no other instructions messing with "v". You should also notice those mysterious "const" specifiers, they are very important.
Read the eighth paragraph.
Quote:
ok new problem, sort of.
using the method I descrbed above I can only access functions that are members of the orbiter vessel class it's self.
what do I need to do to get access to SpiderLEM's functions?
You need to use pointer to SpiderLEM not VESSEL class or use casting since SpiderLEM inherits from VESSEL(shouldn't new addons be inherited from VESSEL3 by the way).
Quote:
[/COLOR]This is the error I get when I call a function unique to spider LEM from LEM_AP.
Code:
1>c:\users\hlynkacg\documents\visual studio 2010\projects\spiderlem\lem_autopilots.cpp(269): error C2662: 'SpiderLEM::StageSeparation' : cannot 'this' pointer from 'const SpiderLEM' to 'SpiderLEM &'
1> Conversion loses qualifiers
You're violating 'const' protection here as far as I can tell. Your pointer to SpiderLEM is const protected and StageSeparation function doesn't respect that.