Title

Sunday, 18 January 2015

Strange behavior of const_cast


Consider the following code:

I declare a new reference end assign it to value a via const_cast. Then I just increase the reference value print the addresses and values.

#include <iostream>  using namespace std;  int main()  {   const int a = 7;   int &b = const_cast<int&>(a);   ++b;   cout<<"Addresses "<<&a<<" "<<&b<<endl;   cout<<"Values "<<a<<" "<<b<<endl;  }    //output  Addresses 0x7fff11f8e30c 0x7fff11f8e30c  Values 7 8

How can i have 2 different values in the same address??

Answer

why not like this ?

document.getELementById("Yes").addEventListener("click",doTask()); document.getELementById("No").addEventListener("click",doNothing());

No comments:

Post a Comment