Add a non member function

Assignment Help C/C++ Programming
Reference no: EM13166113

For the code below add the following. Add a non member function that will run the show function of a Sport object. This object is the one parameter of the function. Make the necessary changes so that when an object of BallSport is the parameter of the function, it will show the correct output (using polymorphism).

#include <iostream>
#include <string>
using namespace std;

class Sport
{
public:
Sport()
{
kind = "who knows";
}
void show()
{
cout << "this is " << kind << endl;
}
private:
string kind;
};

class BallSport : public Sport
{
public:
void set(string bt)
{
balltype = bt;
}
void show()
{
cout << "this is " << balltype << "ball\n";
}
private:
string balltype;
};

int main()
{
return 0;
}

Reference no: EM13166113

Questions Cloud

Where s is any string : Write a function detab(s, stop), where s is any string, and stop is a positive integer called tabstop size. This function should return a string which is like s.
Write a dissociation equation of alcl3 : Write a dissociation equation of AlCl3 showing its sepatation into aqueous ions.
State what is the absolute error in pka according to pka : What is the absolute error in pKa according to pKa from the mid-point pH value? The true value is given in # (5) (9) What is the relative % error in pKa according to pKa from the mid-point pH value?
Find a number alpha mod 8745437489 is not a primitive root : using a computer, show that 7 is a primitive root mod 8745437489. Find a number alpha mod 8745437489 that is not a primitive root
Add a non member function : For the code below add the following. Add a non member function that will run the show function of a Sport object. This object is the one parameter of the function.
What is the partial pressure of each gas : A sample of gas is made entirely of carbon dioxide and water, and there are 259 moles of carbon dioxide and 513 moles of water. If the total pressure of the sample is 21 atm, what is the partial pressure of each gas?
Calculate the concentration of ammonium ions : A solution is prepared by dissolving 11.5 g ammonium sulfate in enough water to make 100.0 mL of stock solution. A 10.00 mL sample of this stock solution is added to 52.00 mL of water. Calculate the concentration of ammonium ions and sulfate ions ..
Make a power table for numbers mod 11 : Make a power table for numbers mod 11. Indicate how the table shows Fermat's theorem, label the primitive roots mod 11. Explain how you can tell they are primitive roots. Label the rows that make good power ciphers and explain
Calculate the volume of required to reach equivalence point : 60.0 mL of a 0.450 M solution is titrated with 0.570 M . Calculate the volume of required to reach the equivalence point.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program to input miles driven and gallons used

Create a program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and display the miles per gallon

  Coinflip to prompt for and input a number

Write a program and name it CoinFlip to prompt for and input a number of times to flip a coin, then to output the number of "heads" and the number of "tails" that were flipped.

  Use a for loop to generate 100 random numbers.

Use a For Loop to generate 100 random numbers. Determine the most current maximum and minimum number as the random numbers are being generated. This is referred tp as a "running" maximum and minimum. Display the running maximum and minimum values as ..

  Write a program that accepts as input, without prompts

Write a program that accepts as input, without prompts, a series of short values, terminated by end of file. The program outputs one line:

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Write a count occurrences() function that accepts a string

Write a CountOccurrences() function that accepts a string to be searched and a sub-string to be found. The function should return the # of times the sub-string is found. Write a tester file that declares a secret sentence as a constant.

  Functions to compute stress and strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads P of 10,000 to 1,000,000 pounds.

  The main program should create an ifstream

For decryption, the main program should create an ifstream for the file to be decrypted. It should use the getline method of the ifstream to read lines from the file, call the encryption / decryption function with the line to be decrypted, and dis..

  Project

Unit 3 Individual Project SSCI210 – 1304B – 01 A typical individual who commits who commits hate crimes whether it is against or aimed at the Gay/lesbian community , the persons of color or the Jewish community, ( I mention these three because they a..

  Implement method to advance any given date by one day

Write C++ implementation of this method. Create and specify any other methods that you require. Include comments which will be helpful to someone who will maintain implementation in the future.

  Show the deatils of an emplyoee - c programming

Show the deatils of an emplyoee in a neat format.

  Compares the number of possible sequences

A c++ program that compares the number of possible sequences of the length L that can be generated uinder the following assumptions. Given an alphabet of size N=9. The program must output a formatted list comparing the number of possible sequences..

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