Getting the Value From a Pointer
I am attempting to get the value from another object, but I can't because it's a pointer. I keep getting :
error C2440: 'initializing' : cannot convert from 'Book *' to 'Book'
I have the parameters as listed. I'm working with nodes, all of which that's "data" is a book.
I'm trying to create a new "Book" to have the same data as another "Book", but right now I only have a pointer which points to the Book's data.
1 2 3 4 5 6
|
Create(Book *n)
{
Node *temp = new Node;
Book newBook = n;
temp->data = newBook;
}
|
How do I convert, or get the value from a pointer?
Use dereference operator: Book newBook = *n;
Topic archived. No new replies allowed.