Hello everyone!

I am trying to figure out what to do here. I'm new at programming and this particular situation has me stumped. Here is what I'm trying to figure out:

I have two classes. One is class Coordinate, and one is class Ship. A Coordinate object is made up of an x, y, and z value (all doubles) and is constructed like this (x, y, z). A Ship object is made up of a coordinate, and an x_inertia, y_inertia, and z_inertia value (also doubles).

Coordinate(double x, double y, double z)
Ship(Coordinate, x_inertia, y_inertia, z_inertia)

I'm using composition because a Ship (has-a) coordinate.

I want to be able to update a Ship's location (Coordinate) using the inertia values via an updateLocation() function.

ex: Ship((5,5,5)1,1,1) ->after updateLocation-> Ship((6,6,6)1,1,1)

I have the code written, but since x, y, and z of class coordinate are protected, I cannot update the locations of the ships unless I "comment" out the "protected" list (thus making the variables "public").

I'm obviously missing something, and I know it's probably simple, but I don't know what. Here is my updateLocation() function:

Ship::Ship(Coordinate position, double new_x, double new_y, double new_z)
: location(position),
x_inertia(new_x),
y_inertia(new_y),
z_inertia(new_z)
{
}

void Ship::updateLocation()
{
location.x += x_inertia;
location.y += y_inertia;
location.z += z_inertia;
}

Any advice? Anything else you need to see?