Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Anonymous Poster

Can someone please help me

This topic is 6756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Iam developing an 3D engine. now i got to a point where i really stuck. Its an openGL game, so anyone that can help me should have it. I will try to show the relevant code here, but it may be that this isnt the code that makes the bug. So if you think you can help me on this, please ICQ me and you will get the full source.(i will make it open source when its ready) Here is the code: class Quad: { public: void setX(float xo0); protected: float xl; } void Quad::setX(float xo0) { xl = xo0; // <-- The Debugger says: Access Violation: ''x1'' } Quad *root; Quad *conductor; void setupWorld() { float x1; root = new Quad; root->next = NULL; conductor = root; if(conductor!=NULL) { do { conductor=conductor->next; x1 = 32.002; conductor->setX(x1); } while(conductor->next!=NULL); conductor->next = new Quad; conductor = conductor->next; conductor->next = NULL; } }

Share this post


Link to post
Share on other sites
Advertisement
root->next = NULL;

Quad doesn''t have a variable named "next" in it. What errors are you getting specifically?

Share this post


Link to post
Share on other sites
sorry i forgot to copy''n''paste it but there is
Quad *next;
in Quad.

It compiles and links but when i execute it, i get a runtime error. I can post what the debugger prints out:

"Unhandled Exception in text.exe 0xC0000005: Access Violation."
Name: xo0 Value: 1.000 // <- this is OK !
Name: this->xl1 Value: CX0030: ERROR: Expression cannot be evaluated.
Name: this Value: CX0030: ERROR: Expression cannot be evaluated.


i think the error is the This pointer.

Share this post


Link to post
Share on other sites
In your do clause, the first thing you do is set conductor to the next pointer of the current conductor. Since on the first iteration, conductor == root and root ->next == NULL, then on the first iteration, conductor will be set to NULL and this conductor ->setX (x) will generate and exeception because this will be NULL.

Tim

Share this post


Link to post
Share on other sites
Look in your SetupWorld function that you posted:

void setupWorld()
{
float x1;

root = new Quad; // <-- OK, root is set
root->next = NULL; // <-- OK, root->next is NULL
conductor = root; // <-- OK, conductor = root

if(conductor!=NULL) // <-- OK, conductor = root != NULL
{
do
{
conductor=conductor->next; // <-- conductor here is NULL
x1 = 32.002;
conductor->setX(x1); // OOPS! Dereferencing a NULL! Bad boy

} while(conductor->next!=NULL);

conductor->next = new Quad;
conductor = conductor->next;
conductor->next = NULL;
}
}


// CHRIS

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i now arranged it as you said, but only for 1 iteration. Can someone please make the Linked List correct.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!