How do I return the flag value in operator++(int)? To make the program error-less, I had to return p. But that is not my output. If I could return the flag value, the checking of flag==0 could have occurred well. I am also doubtful whether I have written all the syntax well.is it even possible to use operator overloading in this case?i want prime operator++(prime y); to pass a value and the prime operator++(int z ) to catch the value and calculate the the flag value.
#include <iostream>
using namespace std;
class prime
{
    private:
        int i , ch ,ans ,j ,flag=0 , y , z; 
    public:
        prime()
        {
            cout <<"1. Check a no to be prime\n";
            cout <<"2. Prime no <100\n";
            cout <<"Enter your choice\n";
            cin >>ch;
            do
            {
                switch(ch)
                {
                    case 1:
                    {
                        int x=45;
                        x=y;
                        prime operator++(prime y);
                        if(flag==2)
                            cout<<"the given no. "<<y<<" is a prime no."<<endl;
                        else
                            cout<<"the given no. "<<y<<" is not a prime no."<<endl;
                        break;
                    }
                    case 2:
                    {
                        cout<<"the primes numbers below 100 are"<<endl;
                        for(i=1;i<100;i++)
                        {
                            i=y;
                            prime operator++(prime y);
                        }
                        if(flag==2)
                            cout<<i ;
                        break;
                    }
                    default:
                    {
                        cout<<"wrong choice"<<endl;
                    }
                    cout<<"press 0 to continue or 1 to exit."<<endl; 
                    cin>>ans;   
                }  // end of switch
            }while(ans==0);// end of do while
        }// end of prime constructor
        prime operator++(int z)
        { 
            prime p;
            for(j=1;j<=p.z;j++)
            {
                if(p.z%i==0)
                    flag++;
            }
            return p;
        }// end of prime operator function;
};//end of class prime
int main()
{
    prime op;
    op++;
    return 0;
}

