I am trying to set the value of a variable contained within a struct which is being pointed to with a smart pointer.
For context:
// Represents a node in the search tree.
struct SNode
{
int x; // x coordinate
int y; // y coordinate
}
The pointer (Declared as unique_ptr<SNode>start
) is called start
.
I am reading in data from a file and this is the problem line:
inFile >> move(start)->x;
Upon execution, this line is executed and the following error occurs within "istream":
"Unhandled exception thrown: read access violation. _Val was nullptr."
I am fairly new to the concept of smart pointers so I don't quite know whether I'm personally doing anything wrong here, so any help is appreciated.