object "monster" says it wasn't declared

object "monster" says it wasn't declared

here is the code

#include <iostream>

using namespace std;


class enemy{
protected:
int attackpower;
public:
void setattackpower(int a){
attackpower=a;
}


};

class ninja: public enemy{
public:
void attack(){
{cout << "i am a ninja -" << attackpower << endl;}
};
class monster: public enemy{
public:
void attack()
{cout << "i am a monster -" << attackpower << endl;}
};
};
int main(){
ninja n;
monster m;
enemy *enemy1 = &n;
enemy *enmey2 = &m;
enemy->setattackpower(10);
enemy2->setattackpower(15);
n.attack()
m.attack()
return 0;
}
I believe you are missing a curly brace to close the class ninja block.
closed account (Dy7SLyTq)
you have a } mismatch
im a real noob sorry but i dont know how to fix it
closed account (Dy7SLyTq)
at attack you have a { bracket next to cout. remove it
ok got thank you so much
Topic archived. No new replies allowed.