How to...
If anyone knows how to dynamically create an array of structures in c++ please let me know.
Thanx.
struct EXAMPLE
{
float x,y;
};
EXAMP *exmp
//some code
exmp=new EXAMP[NUM_OF_ELEMTS];
//some more code
delete exmp; //when done
exmp=0;
HHSDrum@yahoo.com
Polarisoft Home Page
{
float x,y;
};
EXAMP *exmp
//some code
exmp=new EXAMP[NUM_OF_ELEMTS];
//some more code
delete exmp; //when done
exmp=0;
HHSDrum@yahoo.com
Polarisoft Home Page
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
When you allocate with a
exmp=new EXAMP[NUM_OF_ELEMTS];
you should also delete with a
delete[] exmp;
because you allocate an array of EXAMP:s so the compiler knows you''re deallocating an array.
/JanneVee
"Some People even believe that COBOL is a real programming language." Scott Meyers - Effective C++
exmp=new EXAMP[NUM_OF_ELEMTS];
you should also delete with a
delete[] exmp;
because you allocate an array of EXAMP:s so the compiler knows you''re deallocating an array.
/JanneVee
"Some People even believe that COBOL is a real programming language." Scott Meyers - Effective C++
/JanneVee"Some People even believe that COBOL is a real programming language." Scott Meyers - Effective C++
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement