Shawn Curry
10132002, 09:13 AM
I'm writing a routine to calculate prime numbers and basically I need to build and access a table of class objects. Do I have to use a pointer or what?


View Full Version : Arrays of Class Objects? Shawn Curry 10132002, 09:13 AM I'm writing a routine to calculate prime numbers and basically I need to build and access a table of class objects. Do I have to use a pointer or what? maes 10132002, 06:04 PM not necessarily(sp? though word to write). If you know how much objects you're going to need, you can do it like this CString zin[3]={CString("persoon 1"),CString("persoon 2"), CString("persoon 3")}; I know, it is dutch, but I hope you get the point. if you don't know how much objects you'll need, you'll have to use a pointer CString *multiple; multiple=new CString[5]; delete []multiple; CString is just a class I used as an example fivesidecube 10142002, 01:06 PM Shawn, If you are using MFC then you can use the class CArray to manage the whole array. It will dynamically increase the size of the array when required. Stuart. Shawn Curry 10142002, 03:33 PM I've only been programming for about 4 months now and I really dont know that much about the MFC yet. Are there any good references on how to implement the CArray class? I was able to implement the array with a fixed array size, however to compute extremely large prime numbers(200 digits) I need to generate a very LARGE table of primes to check. I'm sure theres some f(x) showing the number of prime numbers between 2 and a given size(as the number size increases, there are less and less prime numbers). The major problem is that to actually compute a 200 digit prime, there must be billions of prime numbers to check against. I plan to implement a relevancy table(it only has to check certain primes for a given number size, therefore I can elimate extraneous candidates from the computation of the next prime, and add them only when they become neccessary). However, the 200 digit prime would have to dump the table to a file on disk, since there would be SO many prime candidates it actually has to check to verify that the number is indeed a prime number. fivesidecube 10152002, 08:52 PM Shawn, I don't fully understand why you are implementing CArray. If you actually talking about creating an instance of the CArray class, then I have found an example here (http://www.expertsexchange.com/Programming/Programming_Languages/MFC/Q_20108081.html). I hope this helps, if not come back. 
 
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum