I have an interesting problem. I'll word this the best I can.
Ok... I have a class. Lets just say its called CPart. CPart has 3 variable members: M1, M2, M3. There are 5 CPart objects. We need a way to go through all 5 objects and compare M1 to a global variable - lets just call it I.
Here is an example that I tried that didn't work. Apparently, you can't create and array of user-defined objects.I hope you can understand my code. I really need some help. (I know I made this post before but I don't think I made it understandable so I decided to make another try).Code:int I = 10; void setVariables(); int numberOfParts; class CPart{ public: int M1; int M2; int M3; }; CPart p1 Cpart p2 Cpart p3 Cpart p4 Cpart p5 numberOfParts = 5; void setVariables(){ (lets just pretend all three variables for each of the five objects is set to 5 in this function) } setVariables(); /*this is the part that I think is the problem*/ CPart listOfParts[numberOfParts]; listOfParts[1] = p1; /*...and so on thru p5*/ for (i=0; i<numberOfParts; i++){ int i = 1; if (listOfParts[i] >= I){ /* DO Something */ } i++ }
Thanks a ton!



LinkBack URL
About LinkBacks



I see the problem with the "i". That was just a stupid mistake I made. The rest is all helpful! Thanks so much!!!