Page 1 of 1

Answer in C++! What is wrong with my code. The output with errors is included. Here's the Coin class definition. Complet

Posted: Fri May 20, 2022 1:39 pm
by answerhappygod
Answer in C++! What is wrong with my code. The output with
errors is included.
Here's the Coin class definition. Complete the missing parts of
the implementation.
Answer In C What Is Wrong With My Code The Output With Errors Is Included Here S The Coin Class Definition Complet 1
Answer In C What Is Wrong With My Code The Output With Errors Is Included Here S The Coin Class Definition Complet 1 (238.71 KiB) Viewed 39 times
Here's the Coin class definition. Complete the missing parts of the implementation. class Coin { public: Coin(double value); -Coin(); double value() const; static int coins(); private: double m_value; static int num_coins; }; coin.cpp 1 #include <string> 2 #include "coin.h" 3 using namespace std; 4 int Coin:: num coins = 0; 5 Coin::Coin(double value) { 6 m value = value; 7 num_coins++; } 9 10 Coin: :-Coin() { 11 12 } 13 14 double Coin::value() const { 15 return m value; 16 } 17 18 int Coin::coins() 19 { 20 return num coins; 21 }

21 } Demo.cpp 1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 #include "coin.h" 6 7 int main() 8 { 9 { 10 Coin a[] = { {.1}, {.25}, {.25} }; 11 cout << "#1 coins: " « Coin:: coins() << endl; 12 } 13 cout << "#2 coins: " « Coin::coins() << endl; 14 { 15 Coin a[] = { {.1}, {.25}, {.25}, {.05}, {.50}, {.01} }; 16 cout << "#3 coins: " « Coin::coins() << endl; 17 } 18 cout << "#4 coins: " « Coin::coins() << endl; 19 } CodeCheck Reset Testing Demo.cpp Actual Expected #1 coins: 3 #2 coins: 3 #3 coins: 9 #4 coins: 9 #1 coins: 3 #2 coins: 0 #3 coins: 6 #4 coins: 0 fail Score 0/1