Decimal Increment

#include <iostream>
using namespace std;
class Decimal
{
  float a;
  public:
  void in()
  {
    cin>>a;
  }
  void operator ++()
  {
   a=a+0.10;
   cout<<a;
  }
};
int main() {
Decimal obj;
  obj.in();
  obj.operator ++();
return 0; }

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include
    using namespace std;
    class Decimal
    {
    float a;
    public:
    void in()
    {
    cin>>a;
    }
    void operator --()
    {
    a=a-0.10;
    cout<<a;
    }
    };
    int main() {
    Decimal obj;
    obj.in();
    obj.operator --();
    return 0;
    }

    ReplyDelete
  3. just give space after operater
    its operator ++ not operator++

    ReplyDelete