Reputation: 4214
I was trying to access a frame that has X and Y co-ordinates using yaml. Things were working fine when I had &frame_node
instead of *frame_node
, but for using the FindValue
function I had to use *frame_node
. However, frame_node[0]
, frame_node[1]
, etc., give me an error now. Could you please help me to solve this issue?
if (const YAML::Node *frame_node = config_node.FindValue("frame")) {
//const YAML::Node &frame_node = config_node["frame"];
std::cout << "Hello" << std::endl;
hasCard = 1 ;
// X-coordinates.
frame_node[0] >> x[0];
frame_node[1] >> x[1];
frame_node[2] >> x[2];
frame_node[3] >> x[3];
// Y-coordinates.
frame_node[4] >> y[0];
frame_node[5] >> y[1];
frame_node[6] >> y[2];
frame_node[7] >> y[3];
}
Upvotes: 1
Views: 542
Reputation: 34044
frame_node
is a pointer, so frame_node[1]
will give you pointer arithmetic. You want (*frame_node)[1]
.
Upvotes: 1