-1
私はこの予想されたプライマリ例外エラーが存在する理由を説明しません!!! ...:'arrayName'の前に期待されるprimary-expression
Running /home/ubuntu/workspace/sample.cpp
/home/ubuntu/workspace/sample.cpp: In function ‘int main()’:
/home/ubuntu/workspace/sample.cpp:50:22: error: expected primary-expression before ‘arrayHelpfull’
std::string arrayHelpfull[3],
^
/home/ubuntu/workspace/sample.cpp:51:10: error: expected primary-expression before ‘double’
double arrayHelpfullPoints[3],
^
/home/ubuntu/workspace/sample.cpp:52:22: error: expected primary-expression before ‘arrayNone’
std::string arrayNone[3],
^
/home/ubuntu/workspace/sample.cpp:53:10: error: expected primary-expression before ‘double’
double arrayNonePoints[3],
^
/home/ubuntu/workspace/sample.cpp:54:23: error: expected primary-expression before ‘arrayHarmfull’
std::string arrayHarmfull[3],
^
/home/ubuntu/workspace/sample.cpp:55:11: error: expected primary-expression before ‘double’
double arrayHarmfullPoints[3],
^
/home/ubuntu/workspace/sample.cpp:61:20: error: expected primary-expression before ‘arrayHelpfull’
std::string arrayHelpfull[3],
^
/home/ubuntu/workspace/sample.cpp:62:8: error: expected primary-expression before ‘double’
double arrayHelpfullPoints[3],
^
/home/ubuntu/workspace/sample.cpp:63:20: error: expected primary-expression before ‘arrayNone’
std::string arrayNone[3],
^
/home/ubuntu/workspace/sample.cpp:64:8: error: expected primary-expression before ‘double’
double arrayNonePoints[3],
^
/home/ubuntu/workspace/sample.cpp:65:21: error: expected primary-expression before ‘arrayHarmfull’
std::string arrayHarmfull[3],
^
/home/ubuntu/workspace/sample.cpp:66:9: error: expected primary-expression before ‘double’
double arrayHarmfullPoints[3],
^
/home/ubuntu/workspace/sample.cpp:74:20: error: expected primary-expression before ‘arrayHelpfull’
std::string arrayHelpfull[3],
^
/home/ubuntu/workspace/sample.cpp:75:8: error: expected primary-expression before ‘double’
double arrayHelpfullPoints[3],
^
/home/ubuntu/workspace/sample.cpp:76:20: error: expected primary-expression before ‘arrayNone’
std::string arrayNone[3],
^
/home/ubuntu/workspace/sample.cpp:77:8: error: expected primary-expression before ‘double’
double arrayNonePoints[3],
^
/home/ubuntu/workspace/sample.cpp:78:21: error: expected primary-expression before ‘arrayHarmfull’
std::string arrayHarmfull[3],
^
/home/ubuntu/workspace/sample.cpp:79:9: error: expected primary-expression before ‘double’
double arrayHarmfullPoints[3],
^
コード:
#include<iostream>
#include<string>
#include<fstream>
void printingItems(
std::string arrayHelpfull[3],
double arrayHelpfullPoints[3],
std::string arrayNone[3],
double arrayNonePoints[3],
std::string arrayHarmfull[3],
double arrayHarmfullPoints[3],
std::string option
) {
std::cout << option << std::endl;
}
int main(){
std::string arrayHelpfull[3] = {"fruits", "soda" , "candy"};
double arrayHelpfullPoints[3] = {20.4,50.2,30.0};
std::string arrayNone[3] = {"chair", "shoe" , "pencil"};
double arrayNonePoints[3] = {0,0,0};
std::string arrayHarmfull[3] = {"meth", "dirtyneedle","ninga"};
double arrayHarmfullPoints[3] = {-20,-50,-30};
int userChoice = 0;
while (userChoice != 4) {
std::cout << "1 - Just Plain Items"
<< std::endl
<< "2 - Helpfull Items"
<< std::endl
<< "3 - Harmfull Items"
<< std::endl
<< "4 - Quit"
<< std::endl;
std::cin >> userChoice;
switch (userChoice) {
case 1:
printingItems(
std::string arrayHelpfull[3],
double arrayHelpfullPoints[3],
std::string arrayNone[3],
double arrayNonePoints[3],
std::string arrayHarmfull[3],
double arrayHarmfullPoints[3],
"Plain"
);
break;
case 2:
printingItems(
std::string arrayHelpfull[3],
double arrayHelpfullPoints[3],
std::string arrayNone[3],
double arrayNonePoints[3],
std::string arrayHarmfull[3],
double arrayHarmfullPoints[3],
"Helpfull"
);
break;
case 3:
printingItems(
std::string arrayHelpfull[3],
double arrayHelpfullPoints[3],
std::string arrayNone[3],
double arrayNonePoints[3],
std::string arrayHarmfull[3],
double arrayHarmfullPoints[3],
"Harmfull"
);
break;
}
}
}
あなたは[mcve]と質問が必要です。 – juanchopanza
なぜ ';'ではなく、 'printItems'の各変数宣言の後に'、 'を使用していますか? – computerfreaker
@computerfreaker関数のパラメータリストです。 – NathanOliver