What Qualifies as a Default Constructor?

2 07 2011

In C++ a default constructor is one that can be called with no arguments. This does not mean a default constructor must have no arguments, just that it can be called with no arguments. So an example of a default constructor is one with no arguments but another is one for which all arguments have been given default values.

class Book{
 public:
   Book();
}; 
class Book{
 public:
   Book(int copies = 0, int edition = 0);
};
Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: