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

  Human and nature dynamics (handy) model

This paper is centered around some results obtained from the Human and Nature Dynamics (HANDY) model. This model is equation 3 in their paper.

  Determine companies which specialize in computer forensics

What needs clarified? it's plainly stated use google to find 3 companies which specialize in computer forensics of those 3 companies write 2 or 3 paragraphs comparing what each company does.

  Explaining initial values of cache tags and cache lines

Assuming that the initial values of the cache tags and the cache lines are completely arbitrary, Also, show how the cache tags will change for each of the above steps. You should justify your answer.

  Program to clear register a

Write a program to clear Register A, add five to Register A 10 times, and place the result in RAM Location $2000. Use a RAM location for holding the counter.

  Represent processor demand in the time interval

Let the function D[i, j] represent processor demand in the time interval (i, j). Prove the following theorem.

  Write a select statement that returns four columns

Write a SELECT statement that returns four columns: VendorName

  Minimum number of edits required to convert string

Given two strings of size m, n and set of operations replace (R), insert (I) and delete (D) all at equal cost. Find minimum number of edits (operations) required to convert one string into another.

  Decision to utilize components influence requirements

Must RMO consider using purchased components in the new CSS? If so, When, must it begin looking for components? How will decision to utilize components influence requirements, design and implementation phases?

  Issue -internet changed political interactions globally

Write a 500 word essay based on the issue of ways in which the internet has changed political interactions globally. These might involve political activity in several specific countries,

  Calculate roots of function by newton-raphson approximation

Best known iterative method for calculating roots of a function f (that is, x-values for which f(x) is 0) is Newton-Raphson approximation.

  What are some factors or requirements

What are some factors or requirements when designing an Active Directory Infrastructure. How do you gather the requirements for the design? Please explain in approximately in two paragraphs.

  Write structured english for clyde-s narrative policies

Lasting more than one day, we permit hotel, taxi, and airfare, also meal allowances. Same times apply for meal expenses." Write down structured English for Clyde's narrative of reimbursement policies.

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