include <iostream>
using std::cout;
using std::endl;
#include <cmath>
#include "number.h"
#include<iomanip>
using std::setw;
number::number()
{
}
// constructor initializes PrimeNumberwith bool as arugment
number::number(bool prime)
{
setPrimeName(prime);
}// end function setPrimeNumber
void number::setprimeNumber()
{
primeNumber=number;
}
bool number::getPrimeNumber()
{
return prime;
}// end function getPrimeNumber
void number::displayOn()
{
cout << "The prime numbers from 2 to 10000 are:\n\n";
}
void number::useDivisionFunction()
{
int count=0;
for (int x = 2; x <= 10000; ++x ) //loop
if (prime(x))
{
++count;
cout << setw( 6 ) << x;
if ( count % 5 == 0)
cout << endl;
}
}
return 0;
bool prime (int n)
{
for ( int z = 2; (n/2) + 1 > z; z++ )
if( n % z == 0 )
return false;
return true;
} // end useDivisionFunction
void number::useSquareFunction()
{
int count=0;
bool prime (int x);
for (int x = 2; x <= 10000; ++x )
if (prime(x))
{
++count;
cout << setw( 6 ) << x;
if ( count % 5 == 0)
cout << endl << endl;
}
return 0;
}
bool prime (int n)
{
if(n < 2)
return false;
if(n == 2)
return true;
if (n % 2 == 0)
return false;
double root = sqrt(double(n))+ 1;
for ( int z = 3; z <= root; z += 2)
if( n % z == 0 )
return false;
return true;
} // end UseSquareFunction
number.cpp
h file
#ifndef NUMBER_H
#define NUMBER_H
class number
{
public:
number();
number(bool prime);
void displayOn();
void useDivisionFunction();
void useSquareFunction();
void setprimeNumber(bool);
bool getprimeNumber();
private:
bool primeNumber; // data member
};
#endif //ends the class declaration
I have a return of 10 errors.
------ Build started: Project: Rho_7 6-30c, Configuration: Debug Win32 ------
Compiling...
number.cpp
number.cpp(38) : error C3861: 'setPrimeName': identifier not found
\number.cpp(42) : error C2511: 'void number::setprimeNumber(void)' : overloaded member function not found in 'number'
number.h(25) : see declaration of 'number'
number.cpp(46) : error C2039: 'getPrimeNumber' : is not a member of 'number'
number.h(25) : see declaration of 'number'
number.cpp(48) : error C2065: 'prime' : undeclared identifier
number.cpp(61) : error C3861: 'prime': identifier not found
number.cpp(73) : error C2059: syntax error : 'return'
number.cpp(76) : error C2365: 'prime' : redefinition; previous definition was 'formerly unknown identifier'
number.cpp(89) : error C2373: 'prime' : redefinition; different type modifiers
number.cpp(104) : error C2562: 'number::useSquareFunction' : 'void' function returning a value
number.h(31) : see declaration of 'number::useSquareFunction'
number.cpp(109) : error C2365: 'prime' : redefinition; previous definition was 'formerly unknown identifier'
Build log was saved at - 10 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========