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

  Searching f and removing certain states from the hash table

use the class hashT, ''Hashing: Implementation Using Quadratic Probing,'' which uses quadratic probing to resolve collision, to create a hash table to keep track of each state's information. Use the state's name as the key to determine the hash addre..

  Create class integerset

Create class IntegerSet for which each object can hold integers in the range 0 through 100. Represent the set internally as a vector of bool values. Element a[i] is true if integer i is in the set. Element a[j] is false if integer j is not in the set..

  Write a program that reads in a list of integer numbers and

Write a program that reads in a list of integer numbers and print out the sum of all numbers, the average, the lowest and the highest value entered. The first input number indicates how many numbers the program is attempting to read. For example, if ..

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Write a c++ program that prompts the user for a double

Write a C++ program that prompts the user for a double that should be between 0 and 100. If the value entered is outside of the interval the program will print an error message. The program should continue to repeat until the user enters an appropria..

  Write function compute square root together with prototype

Write a C++ function called compute together with its prototype that is passed 2 integers, A and B and returns the square root of A2+B2 ,as a double.

  Execute tests and repetitions

Read data from standard input and store them in an array, Execute tests and repetitions

  Insert the missing code in the c program

You are to insert the missing code in the C program given for combinational equivalence checking. This program will interface with the CUDD package and will parse netlist files in ISCAS85 circuit format. Next, BDDs will be created for each circuit an..

  Recognition of the problem by the hsbc

What problem did the HSBC face in this case? What people, technology, and the organization factors were responsible for problem? Did HSBC management correctly recognize the problem?

  Create a website that would allow users to enter and submit

Create a Website that would allow users to enter and submit survey

  This program will simulate the game of hearts

This program will simulate the game of Hearts, which is a four-player trick-taking game using any ordinary deck of playing cards. Each player is dealt thirteen cards. Whoever is dealt the Two of Clubs must lead it to the first trick. Each person p..

  C++ programming uml diagrams

The goal of this lab is to better familiarize you with polymorphism and the factory design pattern, two key components in Assignment

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