Question: I keep getting the following errors when compiled: pokemon.cpp:44:35: error: expected ';' at end of declaration Pokedex* newMode = new Pokedex{NULL,NULL}; ^ ; pokemon.cpp:67:37: warning:

I keep getting the following errors when compiled:

pokemon.cpp:44:35: error: expected ';' at end of declaration

Pokedex* newMode = new Pokedex{NULL,NULL};

^

;

pokemon.cpp:67:37: warning: expression result unused [-Wunused-value]

Pokedex* newOne = new Pokedex; {p,list};

^

pokemon.cpp:67:43: error: expected ';' after expression

Pokedex* newOne = new Pokedex; {p,list};

^

;

pokemon.cpp:67:39: warning: expression result unused [-Wunused-value]

Pokedex* newOne = new Pokedex; {p,list};

^~~~

pokemon.cpp:91:12: warning: generalized initializer lists are a C++11 extension

[-Wc++11-extensions]

return {name,0,-damage,0,0,0,0};

^~~~~~~~~~~~~~~~~~~~~~~~

pokemon.cpp:96:11: warning: generalized initializer lists are a C++11 extension

[-Wc++11-extensions]

I'm having trouble fixing my errors. I'm using GCC on a Mac. Below is my code. Also, I would like the output on screen to show the moveset of each pokemon after its name like this example (this has different names and movesets):

Charmander (Fire) - Growl - Scratch Noctowl (Flying) - Dream Eater - Growl Tepig (Fire) - Takle - Tail Whip Zekrom (Dragon) - Dragon Rage - Thunder Fang Reshiram (Dragon) - Dragon Rage - Fire Fang

Heres my code:

#include

#include

using namespace std;

struct Move

{

string name;

int selfHPEffect;

int otherHPEffect;

int selfAtkEffect;

int otherAtkEffect;

int selfDefEffect;

int otherDefEffect;

};

struct Pokemon

{

string name;

string type;

int centimeterHeight;

int gramWeight;

int hp;

int attack;

int defense;

Move move1;

Move move2;

};

struct Pokedex

{

Pokemon* p;

Pokedex* rest;

};

Pokedex* empty()

{

Pokedex* newMode = new Pokedex{NULL,NULL};

return newMode;

}

bool isEmpty(Pokedex* head)

{

return head->p == NULL;

}

int length(Pokedex* one)

{

if (isEmpty(one))

{

return 0;

}

else

{

return 1 + length(one->rest);

}

}

Pokedex* prepend(Pokemon* p, Pokedex* list)

{

Pokedex* newOne = new Pokedex{p,list};

return newOne;

}

string shortDescription (Pokemon* p)

{

return p-> name + " (" + p->type + " )";

}

string index (Pokedex* head)

{

if (isEmpty(head))

{

return "";

}

else

{

return shortDescription(head->p) + " " + index(head->rest);

}

}

Move simpleAttack(string name, int damage)

{

return {name,0,-damage,0,0,0,0};

}

Move healMove(string name, int hp)

{

return{name,hp,0,0,0,0,0};

}

int main()

{

Pokemon Charmander= {"Charmander","Fire" ,71, 16, 78, 75, 75, simpleAttack("Flame",75), healMove("Heal",60)};

Pokemon Tepig={"Tepig", "Fire", 71, 25, 65, 85, 50, simpleAttack("Flamethrower",85), healMove("Recover",65)};

Pokemon Vaporeon={"Vaporeon", "Water", 61, 17, 60, 69, 69, simpleAttack("Tsunami",60), healMove("Recover",60)};

Pokemon Charizard={"Charizard", "Fire", 71, 8, 39, 52, 43, simpleAttack("Blaze",39), healMove("Cure",25)};

Pokemon Moltres={"Moltres", "Fire", 170, 90, 78, 84, 78, simpleAttack("Solar Power",84), healMove("Safeguard",60)};

Pokedex* head = empty();

head=prepend(&Charmander, prepend(&Tepig, prepend(&Vaporeon,prepend(&Charizard, prepend(&Moltres, empty())))));

cout<< "There are " << length(head) << " Pokemons in the pokedex: " << endl;

cout<< index(head) << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!