Refactoring Code C++

// RefactoringExercise.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include 
/* Compute prime numbers, after Knuth, Vol 1, Sec 1.3.2, Alg. "P". */


class Primes {
  
public:
    const long DEFAULT_STOP = 429496729L;
    /** The first prime number */
    const long FP = 2;

   int MAX = 100;


    void mainMethod(long stopIn) {
     
        long* prime = new long[MAX];

        long stop = DEFAULT_STOP;
        if (stopIn > 0) {
            stop = stopIn;
        }

        prime[1] = FP;       // P1 (ignore prime[0])
        long n = FP + 1;       // odd candidates
        int j = 1;        // numberFound

        bool isPrime = true;  // for 3

        do {

            if (isPrime) {
                if (j == MAX - 1) {
                    // Grow array dynamically if needed
                    long* np = new long[MAX * 2];
                    memcpy(np, prime, sizeof(long) * MAX);
                    MAX *= 2;
                    prime = np;
                }
                prime[++j] = n;  // P2
                isPrime = false;
            }
            n += 2;        // P4

            for (int k = 2; k <= j && k < MAX; k++) {  // P5, P6, P8
                long q = n / prime[k];
                long r = n % prime[k];
                if (r == 0) {
                    break;
                }
                if (q <= prime[k]) {    // P7
                    isPrime = true;
                    break;
                }
            }

        } while (n < stop);        // P3

        for (int i = 1; i <= j; i++)
            std::cout << prime[i] << std::endl;
    }
};



int main()
{
    Primes p;
     p.mainMethod(1000); 

}