我在C++寫一個轉換器形式的意大利lires爲歐元:錯誤:預計','或';'前「{」令牌「和」不能被用作函數
#include <iostream>
using namespace std;
float x;
int converter (x)
{
y = x/1936,27;
return y;
}
int main()
{
cout << "Give me the value: ";
cin >> x;
converter (x);
}
我嘗試編譯它,我看到了兩個錯誤。第一個是:
lire-euro.cpp:8: error: expected ‘,’ or ‘;’ before ‘{’ token
我在括號之前定義了一個函數。爲什麼我應該在'{'
之前放','
或3210? 第二個是:
lire-euro.cpp: In function ‘int main()’:
lire-euro.cpp:17: error: ‘converter’ cannot be used as a function
爲什麼我不能用converter
的功能?這與其他錯誤有關嗎?
第三,雖然不是錯誤時,'converter'可以改寫成'X/1936; int y = 27;'爲了清楚起見。 :) – mars
@mars,你是對的。我沒有看到有逗號。 –