Purchase Solution

Data Structures with C++ (STL)

Not what you're looking for?

Ask Custom Question

Consider the class declaration

class demoClass
{
public:
// assign arguments as initial values for the data members
demoClass(int a = 5, int b = 10);
// function returns the maximum of itemA and itemB
// int max() const;
private:
int itemA, itemB;
};

(a) Give the implementation of the constructor using an initialization list.
(b) Implement the member function max() as an external function.
(c) For each of the following object declarations, give the corresponding initial values for attributes itemA and itemB:

demoClass obj1(7,9); // itemA = ________ itemB = ________
demoClass obj2(12); // itemA = ________ itemB = ________
demoClass obj3; // itemA = ________ itemB = ________

(d) What is the output from each statement, assuming the previous declarations?

cout << obj2.max(); // Output: _________
cout << obj3.max(); // Output: _________

Purchase this Solution

Solution Summary

Data Structures with C++ (STL) are examined.

Solution Preview

(a) Give the implementation of the constructor using an initialization list.
demoClass::demoClass(int a=5, int b=10) {
itemA=a;
itemB=b;
}
(b) Implement the member function max() ...

Purchase this Solution


Free BrainMass Quizzes
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.

C# variables and classes

This quiz contains questions about C# classes and variables.

Excel Introductory Quiz

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

C++ Operators

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

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.