const_cast in c++ -getting errors
<pre><code>include "stdafx.h"
#include &lt;iostream&gt;
using namespace std;

class Foo{
public:
    void func()
    {
        cout&lt;&lt;"Hello!!"&lt;&lt;endl;
    }
};

void some_func(const Foo &amp;f)
{
    //f.func();
    Foo &amp;fr=const_cast&lt;Foo&amp;&gt;(f);
    fr.func();
}
int main()
{
    some_func(Foo &amp;f); //if const declared will add the no of errors from 2 to 3
    return 0;
}
</code></pre>

<p>How to invoke the some_func(const Foo &amp;f)...If i declare the const before Foo parameter in main it shows me error...
But if i'm using the code above i'm getting 2 errors..</p>

<h2>output:</h2>

<pre><code>1&gt;------ Build started: Project: const_cast, Configuration: Debug Win32 ------
1&gt;Compiling...
1&gt;const_cast.cpp
1&gt;c:\documents and settings\beata\my documents\visual studio 2008\projects\const_cast\const_cast\const_cast.cpp(24) : error C2065: 'f' : undeclared identifier
1&gt;c:\documents and settings\beata\my documents\visual studio 2008\projects\const_cast\const_cast\const_cast.cpp(24) : error C2275: 'Foo' : illegal use of this type as an expression
1&gt;        c:\documents and settings\beata\my documents\visual studio 2008\projects\const_cast\const_cast\const_cast.cpp(8) : see declaration of 'Foo'
1&gt;Build log was saved at "file://c:\Documents and Settings\beata\My Documents\Visual Studio 2008\Projects\const_cast\const_cast\Debug\BuildLog.htm"
1&gt;const_cast - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code></pre>
