as for passing a list of classes (i''m assuming it''s an array you mean) you''re changer function should work fine:
class Class_of_Death;void ChangeStuff(Class_of_Death *classlist) {// changes ''someValue'' in the 2nd index in the classlist arrayclasslist[2].someValue = 100;// does the exact same thing but on the 3rd index of classlist(classlist+3)->someValue = 200;}// Declare a list either of these ways, it''s basically the sameClass_of_Death CoD[5];Class_of_Death *Cod = new Class_of_Death[5];ChangeStuff(CoD); // Passes pointer to beginning of arrayChangeStuff(&CoD[0]); // Passes pointer to first index in arrayChangeStuff( (CoD+0) );
Basically I need a function that can exept a Null CFace pointer, then use, thepointer = new CFace[numFace], fill it up, and when the function returns, thepointer points to the faces, HOW?
Is there some reason you don''t want the class to parse/read the file?
short answer to have a function change one of it''s params it has to know where what you want changed lives, if what you want changed is a pointer then you want a pointer to pointer
Note that if *a actually pointed to something YOU HAVE NOW LEAKED THAT MEMORY!
The OOP way of doing this would be something like this (forive my bad htmlisms, I don''t know how you qoute code here)
class CMap { unsigned numVertex; unsigned numFace; vector < CVertex > Vertex; vector < CFace > Face; // shouldn''t tu tv be members of Face? public: // construct Vertex and Face as having 0 size as we don''t // know how big to make them yet CMap() : numVertex(0),numFace(0),Vertex(0),Face(0) {} };
bool CMap::ReadFromStream(istream ∈) { in >> numVertex; if(in.bad()) return false; in >> numFace; if(in.bad()) return false; /* The file will now have numVerticies as 3 floats I assume we hand CVertex the input stream and let it load itself doing things like this is kinda the whole point */ Vertex.reserve(numVertex); // This allocates the space for(int i=0;i if(!Vertex.ReadFromStream(in)) return false; } Face.reserve(numFace); // This allocates the space for(int i=0;i if(!Face.ReadFromStream(in)) return false;<br> }<br> return true;<br>}<br><br>Now as long as Vertex and Face have ReadFromStream methods that<br>understand thier own datatypes and return false if they encouter bad data you are done.<br><br>init your object like so<br><br>CMap map;<br>if(!map.ReadFromStream(ifstream(filename))) cerr << "oops";<br><br>The above can also be changed to use binary files fairly easily, its just often best to start of reading from files that you can edit/create easily in a text editor.<br><br> </i>