const-correctness in void methods and lambda 'trick' <p>I have a method that accepts a reference of an object as const, this method doesn't change anything of the method and the const indicates that, the thing is that this method also calls other method that is within the class and is void, doesn't accept any argument and is also virtual, meaning that the class that extends the base class can override the method BUT it needs to be const as well. Eg:</p> <pre><code>#include &lt;iostream&gt; class Boz { public: virtual void introduce() const = 0; }; class Foo { public: virtual void callable() const { // ... } void caller(const Boz&amp; object) const { callable(); object.introduce(); } }; class Bar : public Boz { public: void introduce() const { std::cout &lt;&lt; "Hi." &lt;&lt; std::endl; } }; class Biz : public Foo { public: void callable() const { std::cout &lt;&lt; "I'm being called before the introduce." &lt;&lt; std::endl; } }; int main(void) { Biz biz; biz.caller(Bar()); return 0; } </code></pre> <p>The output would be:</p> <pre><code>I'm being called before the introduce. Hi. </code></pre> <p>As you can see <code>callable</code> must to be const in order to be called. If I change and do this:</p> <pre><code>class Biz : public Foo { public: void callable() { std::cout &lt;&lt; "I'm being called before the introduce." &lt;&lt; std::endl; } }; </code></pre> <p>It will compile not errors are thrown but the callable method won't be called, but the virtual one as it's defined as const. It's quite obvious.</p> <p>The trickiest part here:</p> <pre><code>class Foo { public: virtual void callable() { // ... } void caller(const Boz&amp; object) const { auto trick = [&amp;] () { callable(); }; trick(); object.introduce(); } }; class Biz : public Foo { public: void callable() { std::cout &lt;&lt; "I'm being called before the introduce." &lt;&lt; std::endl; } }; </code></pre> <p>It works and the <code>callable</code> method is called. No errors like <code>passing 'const ...' as 'this' argument</code>.</p> <p>What I'm trying to do is to call <code>callable</code> without the need of being const and the reason is simple: The method doesn't change anything, he don't have access to the object that is begin passed as argument on <code>caller</code> method then we assume that he doesn't have the need to be <code>const</code> but the compiler throws an error even that way. The real problem is that <code>callable</code> is virtual and classes can extend the base class, implement their own <code>callable</code> and try to call other methods but can't if it's not <code>const</code> as well.</p> <p>What I want is pretty much that, is to know how can I call the virtual method without the need of being const (the reason is pretty much that, I'm kind forcing the users that extends the class and override the <code>callable</code> method to only call <code>const</code> methods and this is not what I want) and of course understand what happens with the lambda and why it works.</p>