0
Solve the following code. Please give me justification that why program is giving the error
#include<iostream> using namespace std; class Demo { int value; public: Demo(int v = 0) {value = v;} void showMessage() { cout<<"showMessage() Function"<<endl; } void display()const { cout<<"display() Function"<<endl; } }; int main() { const Demo d1; d1.showMessage(); d1.display(); return(0); }
1 Antwort
+ 2
You cannot call non-const function with const object. However,
You can call const function, with non-const object.