Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is your code, corrected as I interpreted what you wanted to perform.</p> <pre><code>#include&lt;iostream&gt; #include&lt;fstream&gt; #include&lt;string&gt; using namespace std; class operations { public:void checkout() { cout &lt;&lt; "Check out here!!"; } }; int main() { string item; int choice; operations op; cout &lt;&lt; "What do you want to do? " &lt;&lt; endl; cout &lt;&lt; "Press 1 for checking out " &lt;&lt; endl; cout &lt;&lt; "Press 2 for stocking " &lt;&lt; endl; cout &lt;&lt; "Press 3 looking at recipts " &lt;&lt; endl; cin &gt;&gt; choice; cout &lt;&lt; choice; if(choice == 1) { op.checkout(); } return 0; } </code></pre> <p>First, note that semicolons are needed after class declarations, and not needed after method declarations</p> <p>Second, note that <code>void checkout()</code> in your code would not call the method that you defined in your class, but will instead declare a new method that will simply perform nothing. To call the right <code>void checkout()</code> you have to instatiate an object of type <code>operations</code> and then call its method with <code>op.checkout()</code></p> <p>Last, always declare <code>int main()</code> and place <code>return 0</code> if the executions flow arrives to the end of your program correctly.</p> <p>As a side note, I would probably not use a class in your program, but simply implement the methods correspondent to the user's choice before the <code>main()</code> implementation</p> <pre><code>void checkout() { cout &lt;&lt; "Check out here!!"; } </code></pre> <p>so that you can call them simply with</p> <pre><code>checkout() </code></pre>
    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