Question: The following program generates an error. Why? #include #include using namespace std; class CurrencyConverter { public: string toCurrency; private: int amount; CurrencyConverter ConvMoney ( int

The following program generates an error. Why?
#include
#include
using namespace std;
class CurrencyConverter {
public:
string toCurrency;
private:
int amount;
CurrencyConverter ConvMoney(int amt, string toCurr);
};
CurrencyConverter CurrencyConverter::ConvMoney(int amt, string toCurr){
CurrencyConverter myMoney;
if (toCurr == "Euro"){
myMoney.amount = amt *.89;
}
else if (toCurr == "Yen"){
myMoney.amount = amt *108.67;
}
return myMoney;
}
int main(){
int amountIn;
string strCurr;
CurrencyConverter newMoney;
cout << "Enter the amount to convert and currency:";
cin >> amountIn;
cin >> strCurr;
newMoney = newMoney.ConvMoney(amountIn, strCurr);
return 0;
}
Group of answer choices
The object newMoney should be created using a vector.
The function ConvMoney should be made public to call it in main.
The class should be made in separate files.
Only the amount should be passed as an argument to the function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!