Book : "A constructor with default arguments is equivalent to a default constructor"
Is it always?
Book : "A constructor with default arguments is equivalent to a default constructor"
Is it always?
Yes.
But a default constructor, provided by the compiler gives some value to the variables, but with my own constructor i can give any particular value to the variables.. say 10?
So my constructor is different.
I feel like a fool right now.
Am i totally confused?
Try giving more context to your questions.
A constructor with default arguments is equivalent to a default constructor, meaning that if you provide a constructor with all default arguments then you have provided a default constructor. You can no longer write a separate default constructor, and the compiler will not create one for you. If code that uses your class requires a default constructor, then the constructor you created with all default arguments will be used.
It does not mean that they will necessarily be implemented in exactly the same way. You are correct that you can give your variables values if you write your constructor that are different than what the compiler gives if it provides a default constructor.
I'd suggest you keep reading your book to the end of the section or chapter, work through any examples and problems it provides. Then read it a second time. When you read it a second time, you will have a better idea what each statement it makes is referring to, and so you will have fewer questions. If after you've read the chapter a second time you still are confused, then post the question here.
A default constructor is just one that can be called without any arguments. Therefore, if you have a constructor such that every one of its arguments has a default (for example, a constructor with no arguments at all qualifies), then that constructor can be called without any arguments, and hence is a default constructor. There can be only one default constructor, otherwise the compiler wouldn't know which one to call.
Thanks guys . That helped a lot.