Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Complete the lab13_ex2_starter.cpp by

1. show on the console the sum of all non-inherited data members of every instance in the program by Display() function.

2. the sum function needs to be a class method and having the same name for different classes, therefore only one external Display() fucntion is required

3. this Display() fucntion needs to be defined externally as a global function, void Display(Base &), that takes any instance of Base class or derived from Base class.

4. Should the sum can not be obtained, explain the reason in the comment.

Starter: lab13_ex2_starter.cpp

Submit: lab13_ex2.cpp

#include

class Base
{
public:
int mPublic;
private:
int mPrivate;
protected:
int mProtected;
public:
int get_mPrivate() {return mPrivate;}
int get_mProtected() {return mProtected;}
Base(int pub, int pri, int pro)
{ mPublic = pub; mPrivate = pri; mProtected = pro; }
};

class Pub: public Base
{
public:
int mPublic;
private:
int mPrivate;
protected:
int mProtected;
public:
int get_mPrivate() {return mPrivate;}
int get_mProtected() {return mProtected;}
Pub(int a, int b, int c, int pub, int pri, int pro) : Base(a, b, c)
{ mPublic = pub; mPrivate = pri; mProtected = pro; }
};

class Pri: private Base
{
public:
int mPublic;
private:
int mPrivate;
protected:
int mProtected;
public:
int get_mPrivate() {return mPrivate;}
int get_mProtected() {return mProtected;}
Pri(int a, int b, int c, int pub, int pri, int pro) : Base(a, b, c)
{ mPublic = pub; mPrivate = pri; mProtected = pro; }
};

class Pro: protected Base
{
public:
int mPublic;
private:
int mPrivate;
protected:
int mProtected;
public:
int get_mPrivate() {return mPrivate;}
int get_mProtected() {return mProtected;}
Pro(int a, int b, int c, int pub, int pri, int pro) : Base(a, b, c)
{ mPublic = pub; mPrivate = pri; mProtected = pro; }
};


int main()
{
Base cBase(1,2,3);
Pub cPub(1,2,3,4,5,6);

Display(cPub);
Display(cBase);

return 0;
}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9681592

Have any Question?


Related Questions in Computer Engineering

Review the interactive session on pages 50 and 51 in

Review the Interactive Session on pages 50 and 51 in Management Information Systems: Managing the Digital Firm (11th ed.) of your text. It discusses Air Canada. Answer "Case Study Questions" 1 through 3 on page 51. 1. Ho ...

Answer the following question how do you represent a node

Answer the following Question : How do you represent a node in a deployment diagram? What kinds of information can appear on a node? The response must be typed, single spaced, must be in times new roman font (size 12) an ...

Explain that the biggest problems with adware is that it

Explain that the biggest problems with adware is that it slows down the computers its running on.

Every day your friend commutes to school on the subway at 9

Every day your friend commutes to school on the subway at 9 AM. If the subway is on time, she will stop for a $3 coffee on the way to class. If the subway is delayed she skips the coffee and goes straight to class. The p ...

Uranium vi fluoride is crucial for the enrichment of

Uranium (VI) fluoride is crucial for the enrichment of weapons-grade uranium. If a 1.0 mol sample of helium effuses in 255 s, how many seconds will it take for the same amount of uranium (VI) fluoride to effuse under the ...

Question a simm has a capacity of 32mx64how many 32mx8

Question : A SIMM has a capacity of 32Mx64. How many 32Mx8 DRAMa are reqquired to make this SIMM? How many address lines does the SIMM require? How should the DRAMs Be connected ?

When selecting a new computer identify the key components

When selecting a new computer, identify the key components that drive the performance of the machine. And, if you were to spend additional funds on increasing the computer's performance, which component would provide the ...

Ethics and the information security professionnbspwhat are

ETHICS AND THE INFORMATION SECURITY PROFESSION  What are the ethical dilemmas and challenges faced by information security professionals? Are professional organizations' ethical codes of conduct beneficial as an informat ...

How can deferred cancellation ensure that thread

How can deferred cancellation ensure that thread termination occurs in an orderly manner as compared to asynchronous cancellation?

Systems analysis project personal trainer inc owns and

Systems Analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As