Cogman
Lifer
BTW, thanks for all the help in the OO Design thread. Anywho.
I have a program that decomposes a string, and turns it into a fraction and then reduces the fraction using a vector of primes. Right now, the class has all the functions to decompose the string and then a separate function does the fraction reduction.
Now, part of the separate function job is to grow the prime array as needed. Now, I would really like to have this reducing fraction function as a member function for the class. My problem is that every new object will have a new set of primes and will do the same calculation for more primes over and over again.
Provided that I don't want any global variables. Basically if I know how to get the objects to keep track of themselves I could just allocate the memory off the heap for the first one and pass the pointer back for all the rest.
That, or I could just keep it a separate function from the object. Though I would like to include it because of an upcoming assignment that will need it.
I have a program that decomposes a string, and turns it into a fraction and then reduces the fraction using a vector of primes. Right now, the class has all the functions to decompose the string and then a separate function does the fraction reduction.
Now, part of the separate function job is to grow the prime array as needed. Now, I would really like to have this reducing fraction function as a member function for the class. My problem is that every new object will have a new set of primes and will do the same calculation for more primes over and over again.
Provided that I don't want any global variables. Basically if I know how to get the objects to keep track of themselves I could just allocate the memory off the heap for the first one and pass the pointer back for all the rest.
That, or I could just keep it a separate function from the object. Though I would like to include it because of an upcoming assignment that will need it.