Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-13-2002, 09:13 AM   PM User | #1
Shawn Curry
New Coder

 
Join Date: Oct 2002
Location: middle of nowhere
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Shawn Curry is an unknown quantity at this point
Arrays of Class Objects?

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?
Shawn Curry is offline   Reply With Quote
Old 10-13-2002, 06:04 PM   PM User | #2
maes
Regular Coder

 
Join Date: Jul 2002
Location: Belgium
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
maes is an unknown quantity at this point
not necessarily(sp? though word to write). If you know how much objects you're going to need, you can do it like this
Code:
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
Code:
CString *multiple;

	multiple=new CString[5];
delete []multiple;
CString is just a class I used as an example
maes is offline   Reply With Quote
Old 10-14-2002, 01:06 PM   PM User | #3
fivesidecube
New Coder

 
Join Date: Sep 2002
Location: Up North (UK)
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
fivesidecube is an unknown quantity at this point
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.
fivesidecube is offline   Reply With Quote
Old 10-14-2002, 03:33 PM   PM User | #4
Shawn Curry
New Coder

 
Join Date: Oct 2002
Location: middle of nowhere
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Shawn Curry is an unknown quantity at this point
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.
Shawn Curry is offline   Reply With Quote
Old 10-15-2002, 08:52 PM   PM User | #5
fivesidecube
New Coder

 
Join Date: Sep 2002
Location: Up North (UK)
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
fivesidecube is an unknown quantity at this point
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.

I hope this helps, if not come back.
fivesidecube is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 AM.


Advertisement
Log in to turn off these ads.