Does a constructor / destructor have to have code, or is the function enough?

前端 未结 3 1257
再見小時候
再見小時候 2021-01-24 17:44

So if I have a class

class Transaction {

int no;
char dollar;

public:

    Transaction();
    ~Transaction();
}

And in my constructor / destr

3条回答
  •  面向向阳花
    2021-01-24 18:14

    No, it does not have to have code. In fact, in most languages you can leave it out and it will construct the class properly.

提交回复
热议问题