Can someone please help me
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;
}
}
i am the 2 between 0 and 1
root->next = NULL;
Quad doesn''t have a variable named "next" in it. What errors are you getting specifically?
Quad doesn''t have a variable named "next" in it. What errors are you getting specifically?
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.
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.
i am the 2 between 0 and 1
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
Tim
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
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
// CHRIS [win32mfc]
April 20, 2000 03:00 PM
i now arranged it as you said, but only for 1 iteration. Can someone please make the Linked List correct.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement