I have in my book the following statement:
If we have given any constructor for a class whether it is
1. our own explcit default constructor ( i.e parameterless or with
parameters having default values )
or
2. our own constructor with parameters
Then compiler will not create implicit default constructor.
BUT I have doublt about point 2 and I suspect my book id either incorrect or outdated because my following code does have a constructor with parameters but the compiler is generating internal constructor too.
#include <iostream>
class imminent{
public:
imminent(int x, int y){
std::cout << "I am explicit constructor" << std::endl;
}
};
int main(){
imminent gilfray(); /* compiler creates internal default constructor
that why this line is compiled without errors*/
imminent jimmy(1, 2);
}
Moreover, how can I put my c++ code in real way here as this time I was forced to use JS in the code snippet, isn't there any c++ code sharing option ?