Sample_Program-1
#include<iostream>
using namespace std ;
int main(){
const int i = 9;
int *j = const_cast<int*>(&i); //Ok
int *j = const_cast<int*>(i); //Error
}
Sample_Program-2
#include<iostream>
using namespace std ;
int main(){
const int i = 9;
int j = const_cast<int&>(i);//Ok
int j = const_cast<int>(i);//Error
}
I was just learning some c++ concept and met with the above 2 concepts . Can anyone please explain the concept i marked as error in the above 2 sample program ?