我试图从数组中提取单个值并将它们放入文本中,但是语法会出现错误。
#include <iostream>
#include <ostream>
using namespace std;
// PV, PM, FUE, RAP, PRE, SAB, ESP
int luch_bas [7] = {6,3,5,3,2,1,2};
int main ()
{ cout << "Tiene los atributos siguientes: \n";
cout << "Puntos de Vida (PV)... " luch_bas[0] "\n";
cout << "Puntos de Magia (PM)..." luch_bas[1] "\n";
cout << "Fuerza (FUE) ..." luch_bas[2] "\n";
cout << "Rapidez (RAP) ..." luch_bas[3] "\n";
cout << "Precisión (PRE) ..." luch_bas[4] "\n";
cout << "Sabiduría (SAB) ..." luch_bas[5] "\n";
cout << "Espíritu (ESP) ..." luch_bas[6] "\n";
}
我不断得到的错误日志是&#34;预期&#39 ;;&#39;之前&#39; luch_bas&#39;&#34;,但我不确定遗失的地方;应该去?我确信有更好的方法来编写代码;我还在学习。
答案 0 :(得分:3)
试试这个
int main ()
{ cout << "Tiene los atributos siguientes: \n";
cout << "Puntos de Vida (PV)... \t" << luch_bas[0]<< "\n";
...
}
答案 1 :(得分:2)
我一直得到的错误日志是“预期的”;'在'luch_bas'之前,但我不确定遗失的地方;应该去吗?
您不会像错误消息所暗示的那样放置;
。您希望分别链接输出操作员调用。
std::ostream& operator<<(std::ostream& os, Type t)
会返回std::ostream&
引用,如您所见。
正确的方法是链接operator<<()
来电:
cout << "Puntos de Vida (PV)... " << luch_bas[0] << "\n";
// ^^ ^^
答案 2 :(得分:0)
应该是:
{
"hooks": {
"grunt": false
}
}
答案 3 :(得分:0)
使用更多&#34;流媒体&#34;运营商
#include <iostream>
#include <ostream>
using namespace std;
// PV, PM, FUE, RAP, PRE, SAB, ESP
int luch_bas [7] = {6,3,5,3,2,1,2};
int main ()
{ cout << "Tiene los atributos siguientes: \n";
cout << "Puntos de Vida (PV)... " << luch_bas[0] << "\n";
cout << "Puntos de Magia (PM)..." << luch_bas[1] << "\n";
cout << "Fuerza (FUE) ..." << luch_bas[2] << "\n";
cout << "Rapidez (RAP) ..." << luch_bas[3] << "\n";
cout << "Precisión (PRE) ..." << luch_bas[4] << "\n";
cout << "Sabiduría (SAB) ..." << luch_bas[5] << "\n";
cout << "Espíritu (ESP) ..." << luch_bas[6] << "\n";
}