Implement the member function max as an external


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: _________

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Implement the member function max as an external
Reference No:- TGS01247144

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)