#include "std_lib_facilities.h"
int main()
{
constexpr double euro_to_dollar = 1.11;
constexpr double yen_to_dollar = 0.0081;
double dollar = 1.00;
char unit= 'A';
cout <"Please enter a value followed by e or y: \n";
cin >>dollar>> unit;
if (unit= 'e')
cout << dollar << "Euro == " << euro_to_dollar*dollar << "dollar\n";
else if (unit='y')
cout << dollar << "Yen== " << yen_to_dollar * dollar << "dollar\n";
}
5 error: 'constexpr' was not declared in this scope 5 error: expected ';' before 'double' 7 error: expected ';' before 'double' 15 error: 'euro_to_dollar' was not declared in this scope 17 error: 'yen_to_dollar' was not declared in this scope
我做從編程的問題:原則和由Bjarne Stroustrup的練習使用C++(第二版)。我可以看到我在這裏做錯了什麼。我試圖學習C++,所以我基本上是一個初學者。我很感謝幫助的人。編譯C++錯誤
您正在使用什麼編譯器?它支持C++ 11嗎? –
'cout <「請輸入一個值後跟e或y:\ n」;'應該是'cout <<' –