I understand that's what getter and setter methods are for and what making the variable protected or public is for, but assuming you can't modify the base class, is there any alternate way to set it?
Sure. The alternative way instead of using setter functions in the derived class constructor body, is to use an appropriate constructor from your derived class to call an initializing constructor of the base class (as you state it exists in your comment):
class Base {
public:
Base(int x, int y) : x_(x), y_(y) {}
private:
int x_;
int y_;
};
class Derived : public Base {
public:
Derived() : Base(15,42) {}
// ^^^^^^^^^^^^^
}:
See more details about the member initializer list.