#include<iostream.h>
class A
{
    int avar;
public:
    A()
    {
        avar=0;
    }
    A(int a)
    {
        avar=a;
    }
    void dis()
    {
        cout<<endl<<"avar = "<<avar;
    }
    void operator ++ ();
};
void A::operator ++ () /*[B][U] from compilation message it is known that this is prefix form ,     how do I specify the postfix from [/U][/B]*/
{
    avar++;
}
int main()
{
    A ob1;
    ob1=A(2);
    cout<<endl<<"ob1";ob1.dis();
    ++ob1;
    cout<<endl<<"ob1";ob1.dis();

    cout<<endl;
    return 0;
}

First of all, please use code tags. Second of all, the prefix form should usually have a return value different from void ; it should be the type of what you're implementing. Third, to specify the postfix form, give an int argument: A& operator++(int); .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.