Hola tengo este error y no se porque me da este error:
okemon.cpp: In function 'int main()':
pokemon.cpp:8:2: error: 'cout' was not declared in this scope
cout<<"Batalla inicializada"<<endl;
^
pokemon.cpp:8:2: note: suggested alternative:
In file included from pokemon.cpp:1:0:
/usr/include/c++/5/iostream:61:18: note: 'std::cout'
extern ostream cout; /// Linked to standard output
^
pokemon.cpp:8:32: error: 'endl' was not declared in this scope
cout<<"Batalla inicializada"<<endl;
^
pokemon.cpp:8:32: note: suggested alternative:
In file included from /usr/include/c++/5/iostream:39:0,
from pokemon.cpp:1:
/usr/include/c++/5/ostream:590:5: note: 'std::endl'
endl(basic_ostream<_CharT, _Traits>& __os)
^
pokemon.cpp:12:70: error: 'cin' was not declared in this scope
cout<<"Elije tu ataque:\n1:impactrueno:55\n2:esquivar\n3:rayo:45"; cin>>respuesta;
^
pokemon.cpp:12:70: note: suggested alternative:
In file included from pokemon.cpp:1:0:
/usr/include/c++/5/iostream:60:18: note: 'std::cin'
extern istream cin; /// Linked to standard input
^
pokemon.cpp:47:3: error: 'else' without a previous 'if'
else if (num == 2 && esquivar_pikachu == false){
^
Y este es el codigo:
#include <iostream>
#include <time.h>
int vida_pikachu = 100,impactrueno = 55, esquivar_p = 0, rayo = 45, vida_ash = 100, ataque1 = 45, ataque2= 39, esquivar_a = 0, respuesta = 0, num = 0;
bool esquivar_pikachu = false, esquivar = false;
int main(){
cout<<"Batalla inicializada"<<endl;
while(vida_pikachu > 0 && vida_ash > 0){
cout<<"Turno de pikachu"<<endl;
cout<<"Elije tu ataque:\n1:impactrueno:55\n2:esquivar\n3:rayo:45"; cin>>respuesta;
if (respuesta == 1 && esquivar == false){
vida_ash = vida_ash - impactrueno;
cout<<"Usaste impactrueno"<<endl;
cout<<"La vida actual de ash es: "<<vida_ash<<endl;
}
else if (respuesta == 2 && esquivar == false)
{
vida_ash = vida_ash - esquivar_p;
cout<<"Usaste esquivar"<<endl;
cout<<"La vida actual de ash es: "<<vida_ash<<endl;
}
else if (respuesta == 3 && esquivar == false)
{
vida_ash = vida_ash - rayo;
cout<<"Usaste rayo"<<endl;
cout<<"La vida actual de ash es: "<<vida_ash<< endl;
}else{
cout<<"ash uso esquivar y esquivo tu ataque"
esquivar = false;
}
cout<<"Turno de ash"<<endl;
cout<<"Elije su ataque:\n1:impactrueno:45\n2:esquivar\n3:rayo:39"
if (num == 1 && esquivar_pikachu == false)
{
vida_pikachu = vida_pikachu - ataque1;
cout<<"Ash uso ataque1"<<endl;
cout<<"La vida actual de pikachu es: "<<vida_pikachu<<endl;
}
else if (num == 2 && esquivar_pikachu == false){
vida_pikachu = vida_pikachu - esquivar_a;
cout<<"Ash uso esquivar"<<endl;
cout<<"La vida actual de pikachu es: "<<vida_pikachu<<endl;
}
else if(num == 3 && esquivar_pikachu == false){
vida_pikachu = vida_pikachu - ataque2;
cout<<"Ash uso ataque2"<<endl;
cout<<"La vida actual de pikachu es: "<<vida_pikachu<<endl;
}else{
esquivar_pikachu = false;
cout<<"pikachu uso esquivar y esquivo tu ataque"
}
if (vida_pikachu == 0){
cout<<"Gano ash!!"<<endl;
}
else if(vida_ash == 0){
cout<<"Gano pikachu"<<endl;
}
}
return 0;
}
Te falta añadir using namespace std; justo debajo de donde declaras las librerias.