1. 程式人生 > >Another form of default constructor

Another form of default constructor

Define a book class:

class book
{
public:
  book( int newISBN = 0, string newName = "" ) ;

// Other member functions...
private:
  int ISBN ;
  string Name ; 
} ;

book::book( int newISBN, int newName )
{
  ISBN = newISBN ;
  Name = newName ;
}

Though there are some parameters in constructor, it's also a default constructor. Because all

the data members are assigned a value by default.