Question: I have an issue compiling. Can someone help? Im getting the following error: pokemon.cpp:65:31: error: expected ';' at end of declaration Pokedex* newMode = new

I have an issue compiling. Can someone help? Im getting the following error:

pokemon.cpp:65:31: error: expected ';' at end of declaration

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

^

;

pokemon.cpp:105:30: error: expected ';' at end of declaration

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

^

;

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

[-Wc++11-extensions]

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

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

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

[-Wc++11-extensions]

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

Below is my code (I am using GCC on a Mac)

#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!