This is actually some lab work for a few weeks further into my course and I am just working ahead so that I am somewhat familiar with the concepts involved when we do get this problem in class. Thank you for your help anyway seymore it is most appreciated.
I have created an array of products called P[]. The class product has a method called getProducts() which allows me to enter the details of a product.
I then place this array of products into a vector of products know as product list. How can i assign the variables of the products entered to go directly into the vector so that I will not need to use an array at all.
1 2 3 4 5 6 7 8 9 10 11 12 13
main()
{
product P[3]; //object of type product
order O[3]; // object of type order
for(int i=0;i<3;i++)
{
cout << "\nEnter Product " << (i+1) << " Information";
cout << "\n---------------------------\n";
P[i].getproducts();
}
std::vector<product> productList(P, P + sizeof(P)/sizeof(product));
I have tried to implement the products to the vector using the following method but have been unable to check to see if they have been initialized as I am getting an illegal structure operation on the pointer to the iterator.
I would be very grateful if you could let me know where I am going wrong as I need to be able to write the vector to a DAT file tommorrow and I have not even gotten to the I/O phase yet