I think you're confusing the name of the class with the name of an instance of the class.
In this code int sum; you declare an integer variable named sum.
This is correct. The data type is 'int' and 'sum' names the variable.
The class usage is similar. The data type is 'adi' and the variable names are 'add1' and 'add2'. Here is the correct usage:
class adi
{
public:
int a,b;
};
int main()
{
adi add1;// declare an instance of an adi variable named add1
adi add2;
int sum;// declare an instance of an integer variable named sum
add1.a=10;
add1.b=20;
adi2.a=56;
adi2.b=4;
sum=add1.a+add1.b;
#include "StdAfx.h"
#include "PrimeNUMBER.h"
#include <iostream>
#include <cmath>
using namespace std;
int minNumber = 2;
PrimeNUMBER::PrimeNUMBER(void)
{
}
PrimeNUMBER::~PrimeNUMBER(void)
{
}
bool PrimeNUMBER::ifPrimeNumber(int n)
{
int limit = sqrt(double(n));
for (int i = minNumber; i <= limit ;i++ )
{
if (n % i == 0)
return false;
}
return true;
}
void PrimeNUMBER::factor(int n)
{
int limit = sqrt(double(n));
for (int i = minNumber; i <= limit; i++)
if (n % i == 0)
{
cout << i << ", ";
factor(n / i);
return;
}
cout << n;
}
void PrimeNUMBER::nextPrime (int n)
{
int nextNumber = ++n;
while (!ifPrimeNumber(nextNumber))
{
++nextNumber;
}
cout << "\nNext prime number: " << nextNumber;
}
void PrimeNUMBER::userPrime(int n)
{
if (ifPrimeNumber(n))
cout << "The number is prime.\n";