Show on the console the sum of all non-inherited data member

Assignment Help Basic Computer Science
Reference no: EM13215188

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 <iostream>

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;
}

 

Reference no: EM13215188

Questions Cloud

What will be callies initial capital balance : Callie is admitted to the Adams & Beal Partnership under the bonus method. Callie contributes cash of $20,000 and non-cash assets with a market value of $30,000 and book value of $15,000 in exchange for a 20% ownership interest in the new partners..
Explain what does this indicate the firm''s expected ebitda : Assume that in five years, DigiVault will have an expected exit enterprise value of $48 million, based on an EBITDA multiple of 5.0 from similar exit transactions. What does this indicate the firm's expected EBITDA will be at that time?
Pricing a first to default derivative : Examine the sensitivity of your answers as you vary the number of simulations from 1000, 10,000, 100,000 and 250,000, Pricing a Second to Default Derivative - Pricing a Second to Default Derivative
Define a class named circle : Define a pure abstract base class called BasicShape. The BasicShape class should have the following members.
Show on the console the sum of all non-inherited data member : show on the console the sum of all non-inherited data members of every instance in the program by Display() function.
Prepare all entries required to properly record the sale : On April 1, 2014, West Company purchased $476,000 of 5.25% bonds for $494,790 plus accrued interest as an available-for-sale security. Interest is paid on July 1 and January 1 and the bonds mature on July 1, 2019.
What are the main disadvantages of hypermedia : What are the main disadvantages of hypermedia when compared with conventional media such as books and videos?
How could the company have reduced the costs : In a recent year, an oil refinery in Texas City, Texas, on the Houston Ship Channel exploded. The explosion killed 14 people and sent a plume of smoke hundreds of feet into the air. The blast started as a fire in the section of the plant that incr..
Use the sql command line in oracle to perform : One of a DBA's primary responsibilities is to create and manage database user accounts and to grant or revoke access privileges as needed. Users should be able to access or modify only those parts of the database that they need to perform their jo..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Difference between data block-extent-segment and tablespace

Allocation in Oracle can aid recognize problems more easily. In your own words, give the description of difference between data block, extent, a segment, and a tablespace.

  Capacity as a systems analyst

In your capacity as a systems analyst, you may face situations in which you encounter an ethical dilemma. For example, you may be asked to design a system that supports an activity with which you personally disagree

  Write a method switchpairs that switches the order

Write a method switchPairs that switches the order of elements in a linked list of integers in a pairwise fashion. Your method should switch the order of the first two values, then switch the order of the next two, switch the order of the next two..

  Prove that machine precision as bound for relative round off

Prove that machine precision (epsilon) calculated by mathlab's eps function can be utilized as a bound for relative round off.

  Explain security awareness and training document

Amy walked into her office cubicle and sat down. The entire episode with the blond man had taken well over two hours of her day. Based on this case study, what security awareness and training documents and posters had an impact in this event?

  Explaining models in system analysis and design

In System Analysis and Design: Models are widely used in wide variety of technical occupations beyond information technology.

  How many memory banks are needed

How many memory banks are needed so that a stream of loads can, on average, require only one cycle per load?

  A subroutine in marie assembly that multiplies two value

1)Write a subroutine in MARIE assembly that multiplies two values where the arguments for this subroutine are two pointers(each pointing to a value). The routine, multiply(a,b), performs *a x *b where a's value is the address storing the value being ..

  Determine the date in opening the letter from same file

if /home/jenny/draft and /home/Alex/letter are relates to same file and the following sequence of events occurs, determine the date in opening the letter?

  Describe significance of having test coupled with real users

Describe the significance of having test coupled with real users' views of product at the end of development effort,even if it is test of a prototype and not the completely developed software.

  Computing conditional probability

Pprocessor failed sometime in the interval [4; 8] years. Given this information, what is the conditional probability that it failed before it was 5 years old?

  Explain components of information systems

Using the three components of information systems and the complementary assets concepts, discuss why some companies achieve better results with information systems than others.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd