Note that there are some explanatory texts on larger screens.

plurals
  1. PONo known conversion from pointer to reference to pointer
    primarykey
    data
    text
    <p>I've got the following g++ error</p> <pre><code>Menu.hpp:66:41: error: no matching function for call to ‘Menu::Stack&lt;Submenu*&gt;::push(Submenu*)’ Menu.hpp:66:41: note: candidate is: Menu.hpp:14:21: note: void Menu::Stack&lt;T&gt;::push(T&amp;) [with T = Submenu*] Menu.hpp:14:21: note: no known conversion for argument 1 from ‘Submenu*’ to ‘Submenu*&amp;’ </code></pre> <p>How can such a conversion be impossible? On what sort of occasions does compiler issue such errors?</p> <p>As to what I was actually doing:</p> <ul> <li>I have a class Submenu</li> <li>I have a class Menu which inherits from Submenu</li> <li>Menu has additional field of type <code>Stack&lt;Submenu*&gt;</code> which maps remembering open submenus</li> <li>All methods of Menu like "open menu", "click menu item" and so on refer to the Submenu that is currently on top() of the stack. Within class Submenu, they operate on the object itself.</li> <li>Menu has a public method of closing the current submenu and going up - i.e. popping the submenu from the stack.</li> <li>Menu can pop until it reaches itself, see below what does it mean.</li> </ul> <p>Now is the part that is most probably the issue, namely, the constructor of Menu:</p> <pre><code>Menu() { stack.push( (Submenu*)this ); } </code></pre> <p>It does so because when all menus get closed, methods relative to stack.top() should refer to the Menu itself, being a kind of Submenu too (since it inherits from it).</p> <h1>EDIT:</h1> <p>I've made my own class Stack instead of using std::stack (as I initially suggested) and, as pointed out in the answer, there lied the problem. Excuse me for that inaccuracy.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload