class Object_class {
public:
//unsigned int VertexIndex[MAX_INDEX];
Vertex_class *Vertex;
Face_class *Face;
unsigned int numVertex;
unsigned int numFace;
unsigned int Texture;
float *tu; //Pointer to the list of TU''s
float *tv; //Pointer to the list of TV''s
int active;
int Draw();
Object_class(){active=1;}
inline Object_class &operator = (Object_class &O);
~Object_class()
{
delete Vertex;
delete Face;
delete tu;
delete tv;
}
};
[/source]
The Vertex class is just a class with 3 public x,y,z floats.
[source]
class Face_class {
public:
unsigned int Index[3];
unsigned long TexIndex[3]; //Texture Coord Index
Vertex_class Normal;
inline Face_class &operator = (Face_class &F);
Face_class(){Index[0]=Index[1]=Index[2]=0;}
};
IT DOESNT GET PAST THE FIRST "delete Vertex;", WHY!!!!!!!
It gives me an assert error and points to the line "delete Vertex". Now why, thanks for your time, and please post kinda quick Im leaving in 1 and a half. Thanks a lot
Then Why doesnt this work?
Why doesnt this constructor work? I get an error on the first delete. why?
You did new Vertex, Face, tu, tv somewhere before you delete them didn''t you?
~Kavos
~Kavos
It sounds like kavos is right. Are you actually allocating the memory before you delete it?
sktizo_smurf
Edited by - skitzo_smurf on July 10, 2000 7:19:00 PM
sktizo_smurf
Edited by - skitzo_smurf on July 10, 2000 7:19:00 PM
"Innocent is just a nice way to say ignorant, and stupidity is ignorance with its clothes off."words of,skitzo_smurf
One more thing.. the correct syntax for deleting an array of things is this:
delete [] value ;
So.. here''s your revised destructor code that will never give you an assert error:
Also, this is your own coding style so dont'' feel like you have to do anything but the _class in Object_class, Face_class, and Vertex_class is completely redundant. A lot of programmers begin class names with C (example: CObject, CFace, CVertex), which is a little easier to read, less typing, and still lets you know that the object is a class.
-RWarden (roberte@maui.net)
delete [] value ;
So.. here''s your revised destructor code that will never give you an assert error:
~Object_class (){ if ( Vertex ) delete [] Vertex; if ( Face ) delete [] Face; if ( tu ) delete [] tu; if ( tv ) delete [] tv;}
Also, this is your own coding style so dont'' feel like you have to do anything but the _class in Object_class, Face_class, and Vertex_class is completely redundant. A lot of programmers begin class names with C (example: CObject, CFace, CVertex), which is a little easier to read, less typing, and still lets you know that the object is a class.
-RWarden (roberte@maui.net)
Thanks A LOT for telling me to put the ''[]''. That fixed everything. Also, The reason why I dont make My classes like CFace CObject. I started my engine not thinking about it, And Im too lazey to change everything thanks again.
You really need to initialize your variables in the constructor. I adhere to the rule of ''initialize EVERY member variable to a known state'', which will save you random bugs later. You CAN skip some that don''t matter if you allocate tons of these objects during gameplay, to save some cpu time, but generally you want to init everything. But DEFINATELY set the pointers to NULL. No question about it.
Rock
Rock
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement