# Revision history [back]

but I am new to C++

That may be something to fix first. However what you ask is not very difficult, and I would say actually identical between C and C++.

and looking at the ROS C++ tutorial I can't clearly see how to access the data fields in a complex message that is three or four fields deep.

The same way you would when traversing a C struct which has embedded structs: by using the dot operator to access individual structure members. Accessing members in nested structs just requires recursive use of the dot operator.

but I am new to C++

That may be something to fix first. However what you ask is not very difficult, and I would say actually identical between C and C++.

and looking at the ROS C++ tutorial I can't clearly see how to access the data fields in a complex message that is three or four fields deep.

The same way you would do it when traversing a C struct which has embedded structs: by using the dot operator to access individual structure members. Accessing members in nested structs just requires recursive use of the dot operator.

but I am new to C++

That may be something to fix first. However what you ask is not very difficult, and I would say actually identical between C and C++.

and looking at the ROS C++ tutorial I can't clearly see how to access the data fields in a complex message that is three or four fields deep.

The same way you would do it when traversing a C struct which has embedded structs: by using the dot operator to access individual structure members. Accessing members in nested structs just requires recursive use of the dot operator.

Edit:

Does that mean that, if my custom messages only contain fields that ultimately "resolve" to basic types, I can access them like I would with a C structure?

Yes, that's how this works.

It's just that with C++ those members could/would be actually objects, so they can have methods, which you can then directly invoke on those members.