Purchase Solution

Data Structures C++

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

Solution Summary

The expert determines what is wrong with a code.

Solution Preview

Please see the attached file.

8. What is wrong with the following code?

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

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.