What is an “operator int” function?

前端 未结 5 1079
南旧
南旧 2020-12-08 02:10

What is the \"operator int\" function below? What does it do?

class INT
{
   int a;

public:
   INT(int ix = 0)
   {
      a = ix;
   }

   /* Starting here:         


        
5条回答
  •  暖寄归人
    2020-12-08 03:00

    Seems like it's a question from a classroom, so I'll invite you to check the documentation on how to create a class.

    class Foo
    {
    public
        Foo() {} // Constructor
    
        Foo operator++ {} // Operation ++ on foo like:
        // Foo foo;
        // foo++;
    };
    

提交回复
热议问题