Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Operator '<<' error
    text
    copied!<p>I have a question regarding a homework assignment.</p> <p>I have two classes. One is called ticket.cpp, and the other is called TicketOrder.cpp</p> <p>The main is within the ticket.cpp.</p> <p>I am using a g++ compiler on Linux.</p> <p>What I'm doing is trying to is print out a vector of a <code>TicketOrder</code> object called orders, but it gives me the following error:</p> <blockquote> <p>ticket.cpp:57: error: no match for 'operator&lt;&lt;' in 'std::cout &lt;&lt; orders. std::vector&lt;_Tp, _Alloc>::operator[] with _Tp = TicketOrder, _Alloc = std::allocator'</p> </blockquote> <p>Here is my code:</p> <h3>ticket.cpp</h3> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;limits&gt; #include &lt;cctype&gt; #include "TicketOrder.cpp" using namespace std; int main () { int numberoftickets=0; string input2; char input3; int profit=0; vector &lt;TicketOrder&gt; orders; int atotalmoney=0; int btotalmoney=0; int ctotalmoney=0; int dtotalmoney=0; int etotalmoney=0; do { cout &lt;&lt; "\nPick a ticket that you would like to buy: \n\n"; cout &lt;&lt; "(A) Students without an activity card: $2.00 \n"; cout &lt;&lt; "(B) Faculty and staff: $3.00 \n"; cout &lt;&lt; "(C) USC alumni: $5.00 \n"; cout &lt;&lt; "(D) UCLA students and alumni: $20.00 \n"; cout &lt;&lt; "(E) Everyone else: $10.00 \n"; cin &gt;&gt; input3; if (input3=='A') { cout &lt;&lt; "How many tickets do you wish to buy? " &lt;&lt;endl; if (numberoftickets &gt;0) { TicketOrder order; order.setQuantity(numberoftickets); order.setType(input3); orders.push_back(order); for (int i=0; i&lt; orders.size(); i++) { cout &lt;&lt; orders[i]; } } } else { cout &lt;&lt; "Sorry did not recognize input, try again. " &lt;&lt; endl; } } while (input3 != 'S'); </code></pre> <h3>TicketOrder.cpp:</h3> <pre><code>#include &lt;iostream&gt; using namespace std; class TicketOrder { public : //Getters int getQuantity() const { return quantity; } char getType() const { return type; } //Setters void setQuantity (int x) { quantity=x; } void setType(char y) { type =y; } private: char type; char quantity; }; </code></pre>
 

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