This is a review for a test. I have attempted numerous things and maybe I've just been trying too long and need a rest haha but this is the problem and what I have.
a. Write the definition of the function setData of classTwo.
b. Write the definition of the function print of classTwo.
class One
{
public:
void print() const; //print x and y
protected:
void setData(int a, int b); //set x to a and y to b
private:
int x;
int y;
};
class Two: public One
{
public:
void setData(int a, int b, int c);//x to a, y to b, z to c
void print() const; //print x, y, z
private:
int z;
};
and this is what I have (I know its TOTALLY wrong):
1 2 3 4 5 6 7 8 9 10 11 12 13
void One::setData(int a, int b)
{
x=a;
y=b;
cout<<"x="<<x<<" y="<<y<<endl;
}
void Two::setData(int a, int b, int c)
{
z=c;
}
I couldn't figure out how to access those members without first defining class One? Please can someone help? Not looking for answers, just a clear explanation of what I'm overlooking! PLEASE! :/ oh and just part a.. I think once I understand part A, I can understand part B.