I'm using a class to generate a list of primes.
Im checking a series of numbers being incremented by two
against the current vector of primes to see if any primes divide
into the number evenly.
If no primes divide into it I add the number onto the end of the list of primes
and continue until I have reached an inputted value.
IT is suposed to output every prime up to the inputted value
#include<iostream>
#include<iomanip>
#include<vector>
#include<stdexcept>
using namespace std;
class Primelist
{
private:
void Populate(float limit);
public:
long val;
bool flag;
int intval;
float longval;
float convert;
vector<float> primelist;
vector<float>::iterator prime_Iter;
bool Primechecker(int);
bool Primelistcheck(float subject);
void Print();
Primelist(float limitconstruct);
};
//------------------------------------------------------------------------------
int main()
{
float input;
cout << "Enter the limit of your prime search.\n";
cin >> input;
Primelist primes(input);
primes.Print();
cin.get();
cin.get();
return 0;
}
//------------------------------------------------------------------------------
Primelist::Populate(float limit)
{
for (float p=2; p<20; p++ )
{
if ( Primechecker(p) == true )
primelist.push_back(p);
}
for ( float i=21; i<val ;i+=2 )
{
flag = true;
flag = Primelistcheck(i);
if (flag = true)
primelist.push_back(i);
}
}
Primelist::Primelistcheck(float subject)
{
for ( prime_Iter = primelist.begin(); prime_Iter != primelist.end(); prime_Iter++ )
{
longval = i/ *prime_Iter;
intval = longval;
convert = intval;
if (longval == convert)
{
return false;
}
return true;
}
Primelist::Print()
{
for (int c=0; c<primelist.size(); c++)
{
cout << primelist[c] << endl;
}
}
Primelist::Primechecker(int num)
{
for (int i=2; i< num/2+1; i++)
{
if (num % i == 0)
return false;
}
return true;
}
Primelist::Primelist(float limitconstruct)
{
val = limitconstruct
flag = true;
intval = 0;
longval = 0;
convert = 0;
vector<float> primelist;
vector<float>::interator prime_Iter;
Populate(val);
}
My compiler tells me that I cannot declare the function Primelist(float) without a type
and that the prototype for it does not match any in class 'Primelist'
Any help would be appreciated