#include <new>
#include <list>
#include <ctime>
#include <iostream>
#include <exception>
typedef unsigned long long ulong;
using namespace std;
class SieveOfAtkin
{
private :
ulong Limit;
bool *IsPrime;
list<ulong> Primes;
public :
SieveOfAtkin() { }
SieveOfAtkin(ulong Limit)
{
this->Limit = Limit;
try
{
IsPrime = new bool[Limit];
}
catch(bad_alloc&)
{
cerr << "\n Memory allocation unsuccessful." << endl;
}
}
void Display();
};
void SieveOfAtkin::Display()
{
for(ulong i=0;i<Limit;i++)
cout<<IsPrime[i]<<" ";
}
int main ()
{
SieveOfAtkin Object = SieveOfAtkin(10000000LLU);
Object.Display();
return 0;
}
But if I consider IsPrime array as static I get error. How can I do the same job declaring IsPrime as static? I have to use aforesaid try and catch block. Please help.

New Topic/Question
Reply




MultiQuote





|