Aug 5, 2016 at 5:41pm Aug 5, 2016 at 5:41pm UTC
I can not find any relevant information on the error I am getting.
1 2 3
Library.cpp:25:33: error: conversion from ‘Book*’ to non-scalar type ‘Book’ requested
Book btemp = holdings.at(i);
Book is a class in another file
Holdings is a vector.
I want to make a temp holding location for the information at location i
1 2 3 4 5 6 7 8 9
string Library::checkOutBook(string pID, string bID)
{
for (int i = 0; i < holdings.size(); i++)
{
Book btemp = holdings.at(i);
if (bID != btemp.getIdCode())
}
}
not sure what the error is about.
I read over this
http://www.cplusplus.com/forum/beginner/25109/
and it did not lead to a solution.
Last edited on Aug 5, 2016 at 5:41pm Aug 5, 2016 at 5:41pm UTC
Aug 5, 2016 at 6:03pm Aug 5, 2016 at 6:03pm UTC
I guess the real question boils down to how to I make a temp object so I can run some checks?
Aug 5, 2016 at 6:27pm Aug 5, 2016 at 6:27pm UTC
What data type is "Holdings" a vector of?
Aug 5, 2016 at 6:36pm Aug 5, 2016 at 6:36pm UTC
it is
vector <Book*> holdings;
Aug 5, 2016 at 6:40pm Aug 5, 2016 at 6:40pm UTC
vector <Book*> holdings;
A vector containing pointers to books.
Aug 5, 2016 at 6:53pm Aug 5, 2016 at 6:53pm UTC
number 1 worked just wondering why I need to Dereference the pointer returned by at().
Aug 5, 2016 at 6:59pm Aug 5, 2016 at 6:59pm UTC
holdings.at(i) returns a pointer. You either store that pointer in another pointer, or deference to type (Book).
Aug 5, 2016 at 7:04pm Aug 5, 2016 at 7:04pm UTC
aaaa ok cool thank you both.