
Patrick B. answered 03/04/20
Math and computer tutor/teacher
Here is an example
using namespace std;
#include <iostream>
class X
{
protected:
int x;
public:
X(int n) { x = n; }
int GetX() { return(x); }
};
class Y: public X
{
protected:
int y;
public:
Y(int n, int x) : X(x) //calls parent constructor
{
y = n;
}
int GetY() { return(y); }
};
int main()
{
Y y(4,3);
cout << y.GetX() << endl;
cout << y.GetY() << endl;
return 0;
}