Hello, I have a problem that explodes my head :
I'm doing a script in C ++ with the purpose of making a game. All was well when I ended up in a case that, from what I researched, I found no solution in ST. 1st the script, then the problem itself:
#include "stdafx.h"
#include "finish.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <time.h>
#include <random>
#include "enemy.h"
#include "player.h"
using namespace std;
int main() {
finish d;
cout << "Welcome to the most epic game ever!" << "\n\n";
string action;
int rnd;
rnd = d.random_calc(1,2);
switch(rnd){
case 1:
Monster *enm;
enm->Encounter(enm->type);
break;
case 2:
Ninja *enm;
enm->Encounter(enm->type);
break;
}
cout << "Actual life:" /*<<*/ << endl;
Player p(10, 15, enm());
p.actionPrompt(&action, true);
cout << action;
d.end();
}
Not to take up too much space, follow the Github repository link for this project (With all classes, I recommend seeing them to make it easier for me to respond)
The problem, after all. I have to choose, in the program, between creating one of two classes: "Monster" and "Ninja", both derived from the class "Enemy". Now, I get compilation errors for the created classes, because they are created as local (within the switch) and can not be accessed outside of it.
Please, if you know, Give me a solution!