1 #ifndef COIN_H 2 #define COIN_H 3 4 class Coin 5 { 6 public: Coin(double value); -Coin(); double value() const; 8 10 private: 11 12 }; double m_value; 13 14 #endif Demo.cpp 1 #include 2 #include 3 using namespace std; 4 5 #include "coin.h" 6 7 int main() { 9. { Coin a[] = { {.1}, {.25}, {.25} }; 10 11 cout « "#1 coins: « Coin::coins () « endl; 12 } cout « "#2 coins: « Coin::coins () « endl; 13 14 { Coin a[] = { {.1}, {.25}, {.25}, {.05}, {.50}, {.01} }; cout « "#3 coins: 15 16 « Coin::coins() « endl; 17 } 18 cout « "#4 coins: « Coin::coins () « endl; 19 }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

hi, i need to modify the class definition by adding the necessary data mem and proto. for the coin function given in the class. that function (coin()), returns the num of coins that exist at any time in the program. I'm unsure of how to implement it, please help me implement the function and explain!! in C++ please and thank you

coin.h
#ifndef COIN_H
#define COIN_H
1.
4
class Coin
{
6.
public:
7
Coin(double value);
-Coin();
double value() const;
private:
double m_value;
8.
10
11
12 };
13
14
#endif
Demo.cpp
1 #include <iostream>
2 #include <vector>
3 using namespace std;
4
#include "coin.h"
int main()
{
9.
7
8.
{
10
Coin al) = { {.1}, {.25}, {.25} };
11
cout « "#1 coins:
« Coin::coins () « endl;
12
}
13
cout « "#2 coins:
« Coin::coins () « endl;
{
Coin a[]
14
{ {.1}, {.25}, {.25}, {.05}, {.50}, {.01} };
« Coin::coins () << endl;
15
16
cout « "#3 coins:
17
}
18
cout « "#4 coins:
« Coin::coins () « endl;
19
}
Transcribed Image Text:coin.h #ifndef COIN_H #define COIN_H 1. 4 class Coin { 6. public: 7 Coin(double value); -Coin(); double value() const; private: double m_value; 8. 10 11 12 }; 13 14 #endif Demo.cpp 1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 #include "coin.h" int main() { 9. 7 8. { 10 Coin al) = { {.1}, {.25}, {.25} }; 11 cout « "#1 coins: « Coin::coins () « endl; 12 } 13 cout « "#2 coins: « Coin::coins () « endl; { Coin a[] 14 { {.1}, {.25}, {.25}, {.05}, {.50}, {.01} }; « Coin::coins () << endl; 15 16 cout « "#3 coins: 17 } 18 cout « "#4 coins: « Coin::coins () « endl; 19 }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY