Question: I am getting following error `error: invalid conversion from ‘const int*’ to ‘int*’`
Following is my program

```
#include <set>
int main ( int argc, char **argv) {
    std::set<int> intSet;
    intSet.insert(1);
    intSet.insert(2);
    intSet.insert(3);
    intSet.insert(4);
    intSet.insert(5);

    int *pAddress = &(*(intSet.find(4)));
}

```

I want address of the element in the `std::set` , This code does not give any compilation error with Microsoft compiler but `g++` is giving this compilation error.

Answer: 
GCC [defines](http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14410) `set::iterator` to be `set::const_iterator`, preventing you from binding a non-`const` reference or pointer to the result of `set::find()`. This behaviour is allowed by C++11 (which states that keys are immutable, and that `set::iterator` is a constant iterator), but was incorrect in C++03.

In C++03, you shouldn't modify the elements of a set since that can break the ordering of elements within it. In some cases, you might want to - if the type is a class, and only some members are used to define the ordering, then it was valid to modify other members. The C++03 standard allows this, but you must be careful not to modify the order as that will give undefined behaviour. In C++11, this isn't allowed, and the implementation may prevent this.

In your case, you can't legally modify the value at all, so you can fix your code for C++11, and also improve its safety, by binding to a pointer-to-const.

```
int const *pAddress = &(*(intSet.find(4)));

```
The values of the set are meant to be immutable so that the class can guarantee that all of the elements are unique. Giving you a non-`const` pointer would make it too easy for you to change the value, which would break the design of the set template class ([http://msdn.microsoft.com/en-us/library/e8wh7665(VS.80).aspx](http://msdn.microsoft.com/en-us/library/e8wh7665%28VS.80%29.aspx)).

You should change the last line to have a "const" in front of it like so:

```
const int *pAddress = &(*(intSet.find(4)));

```

FYI: Your code gives an identical compilation error in Visual Studio 2010.