Another Form of Default Constructor

xiaoxiao2021-03-05  22

Define a book clas:

Class book {public: Book (int newisbn = 0, string newname = "); // other member functions ... private: int isbn; string name;}; cook :: book (int newisbn, int newname) {ISBN = Newisbn; Name = newname;}

Though There Area Some Parameters in Constructor, It's Also A Default Constructor. Because All the data members Are Assigned a value by default.

转载请注明原文地址:https://www.9cbs.com/read-38591.html

New Post(0)