#include<iostream>
using namespace std;
class test {
public:
void display() const {
cout<<"Hai Here in class"<<endl;
}
};
int main() {
const test b;
b.display();
}
When I execute the above code I got an error saying "uninitialized const b". But if I provide a default constructor it will compile without any error.
My question is, doesn't compiler provide the default constructor when we declare an object of type const? Any help is much appreciated.
Thanks in advance.