Computer Science Homework Solutions
Problem
#103461

Data Structures C++

What is wrong with the following code?

class classA
{
protected:
void setx(int a);
//Postcondition: x = a
private:
int x;
};
.
.
.
int main()
{
classA aObject;

aObject.setx(4);
return 0;
}


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 = u; y = v
private:
int x;
int y;
};

class two: public one
{
public:
void setData(int a, int b, int c);
//Postcondition: x = a; y = b; z = c
void print() const;
//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.

Solution
What is this?
By OTA - Overall OTA Rating
Xiao Liu, MS - 4.7/5
Purchase Cost Now
$2.19 CAD (was ~$15.96)
Included in Download
  • Plain text response
  • Attached file(s):
    • chap2#8.doc
    • classonetwo.cpp
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • CountLetters.cpp C++ - Please enhance this program so that it would output a list of all the letters that occur in the text together with the number of times each letter occurs, listed in descending order by frequency. ...
  • Data Structures C++ - Find the syntax errors in the definitions of the following classes. See attached file for full problem description.
  • Binary Trees C++ - Write the definition of the function leavesCount that takes as a parameter a pointer to the root node of a binary tree and returns the number of leaves in a binary tree. Add this function to the class ...
  • Java Program - Clock - I've attached the problems so please download the file. Thanks! Please see attached file for full problem description. Develop and execute programs for this exercise. Submit your results to COL. ...
  • Programming in Java II - Two common attributes of a person are the person’s first name and last name. - Please see attached file for full problem description. Example 1-1: Two common attributes of a person are the person’s first name and last name. The typical operations on a person’s name are to se ...
Browse