Why does this work:
#include<iostream>
using namespace std;
class student{
int rollNumber;
int age;
public :
student(){
}
};
int main(){
student const s;
}
But this does not work?
#include<iostream>
using namespace std;
class student{
int rollNumber;
int age;
};
int main(){
student const s;
}
In both cases, there is a default constructor.
The top one has a user-defined default constructor, and the bottom one has the built-in default constructor.
Is there any difference between the default built-in constructor and a non-parameterized user-created default constructor?
In the second one, will the built-in default constructor be the same as the user-defined non-parameterized constructor?
Is there anyone who knows why this is happening?