I have having difficulty with both parts (a&b) of this problem and am not entire
ID: 3786355 • Letter: I
Question
I have having difficulty with both parts (a&b) of this problem and am not entire sure that what if have is correct. Please help.
9. Consider the following code class one public: void print const; //outputs the values of x and y protected: void setData (int u, int v) //Postcondition x ui y v private: int xi int y; class two: public one public: void setData (int a int b int c) //Postcondition x av y br z cr void print consti //outputs the values of x, y, and z private: int z; a. Write the definition of the function setData of the class two. b. Write the definition of the function print of the class two.Explanation / Answer
Please let me know in case of any issue.
class one{
public:
void print() const;
protected:
void setData(int u, int v);
private:
int x;
int y;
};
class two : public one{
public:
void setData(int a, int b, int c)
void print() const;
private:
int z;
};
// defination of setData of class two
void two::setData(int a, int b, int c){
one::setData(a, b); // calling parent class(class one) methos
z = c;
}
// defination of print of class two
void two::print() const{
one::print(); // calling parent class(class one) methos
cout<<"Z: "<<z<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.