Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following definition of class Aclass (along with the definitions of its member functions). class Aclass ( k A (30 pts) . public

Given the following definition of class Aclass (along with the definitions of its member functions). class Show the output produced by each of the following statements: 14 pts aobjl.print(); cobj.print();

Given the following definition of class Aclass (along with the definitions of its member functions). class Aclass ( k A (30 pts) . public 1 private: . . . . . Aclass(); Aclass( char ch, int num), int getvaluel() void print() char letter int valuel; Write the definition of the class named Bclass as follows: 6 pts It has the private data members firstm (integer value) and secondm (object of the class Aclass). /default value for data member letter is 'Z' and that for data member valuel is 0 return the value of the data member valuel print the values of the two data members It has the default constructor (the initial value for data member firstm is 10) and the constructor with a parameter for each of its data members. b. Write the definitions of the default constructor, the constructor with parameters and the member functions print() and computeSum() of class Bclass. 20 pts. It has a void public member function print() that outputs the values of its data members. It has a public member function int computeSum() that computes and returns the sum of the data members secondm.valuel and firstm. c. Write a statement to define the object of the class Bclass named bobj initialized with the value 'A' for data member secondm letter, 20 for data member secondm.valuel, and 30 for data member firstm. 4 pts B. (40 pts) a. Write the definition of the class named Cclass that is derived from (inherits) class Aclass as follows: 6 pts It has an additional private data member firstom (integer value). . It has the default constructor (the initial value for data member firstm is 5) and the constructor with a parameter for each of its data members. The member function print() is overridden in this class: it also outputs the value of data member first in addition to the data members inherited. It has a public member function int computeSum() that computes and returns the sum of the data members value! and firstm. b. Write the definitions of the default constructor, the constructor with parameters and the member functions print() and compute Sum() of class Cclass. 20pts. c. Assume given the following definitions of objects and function process(): Aclass aobil, aobj2( Z, 60). Celass cobj( 'K', 90, 70): void process( Aclass obj) 1 obj.print(); Show the output produced by each of the following statements: 14 pts aobjl.print(); cobj.print(); cobj.Aclass:: print(); process(aobj2 ); process(cobj); aobj1 = cobj; aobj1.print();

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

The output of each statement is as follows aobj1print Outputs Z 60 cobjprint Outputs K 90 70 cobjAcl... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

More Books

Students also viewed these Programming questions

Question

How do management accounting and financial accounting differ?

Answered: 1 week ago

Question

Calculate the missing values

Answered: 1 week ago