ERROR C2664

Hi,

I'm new at this so heres my problem. im creating an online library and im stuck on one part of my code..

When I build solution, it gives me this error "error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'int' to 'const Item &'"

and

"error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)'"

I tried everything to fix it but it just wouldnt work at all.. can anyone help me please?

heres the code

	        int buyNo;
                vector<Item> items;
                bool finished = false;
                cout << "Enter the itemID (Example: 4) Type 0 when you are finished" << endl;
                while (finished == false)
                {
                cin >> buyNo;
error 1 is this line            items.push_back(buyNo);
                    if (buyNo == 0) {
                        finished = true;
                  	
					}
                }

                cout << "You have chosen:" << endl;
                for (int i=0;i<(int)items.size();i++)
                {
Error 2 is this line    cout << items.pop_back() << endl;
                } 



Thank you so much for looking!!!! much appreciated
Last edited on
std::vector pop_back returns void.
http://www.sgi.com/tech/stl/Vector.html
error C2664: 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'int' to 'const Item &'
You're trying to push an int to a vector of 'Item's.

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)'
std::vector::pop_back() doesn't return anything, and you can't send nothing to std::cout.
kbw.. thanks for the link and thanks for helping!!!!!!

helios.. yeh know the problem with the first error but i just dont know how to sort it out, if you can help me with that, that would be great!

THANK YOU GUYS
You need to show us what an Item is. It's not obvious you work out an Item given an ItemID.
For the first error, there is no implicit type conversion available to do the conversion. Implicit type conversions can be created via a single-argument constructor or a conversion operator.

For the second, consider using the vector::back() method for the output before calling pop_back().
Last edited on
Topic archived. No new replies allowed.