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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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