Przy wyborze bohatera uruchamia się konstruktor i zawiesza program. Taki komunikat się pokazuje z debugera. http://zapodaj.net/6221d03683b14.png.html
main.cpp
#include <iostream>
#include "headlines.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
using namespace std;
Game game;
int main()
{
char wybor;
cout << "\t" << "HERO" << endl << endl;
cout << "1. New game" << endl;
cout << "2. Load game" << endl << endl;
cout << "Wybor: ";
wybor = getch();
switch(wybor)
{
case '1':
{
game.new_game();
break;
}
case '2':
{
game.load_game();
break;
}
default:
{
system("cls");
cout << "Please input number!";
}
}
return 0;
}
headlines.h
#include <iostream>
using namespace std;
typedef void v;
class Game
{
public:
v new_game();
v load_game();
};
class Heroes
{
protected:
int HP, strength;
public:
void lvl_up();
};
class Warrior :private Heroes
{
int strength;
public:
Warrior()
{
strength = 30;
HP = 75;
}
~Warrior(){}
friend class Game;
};
class Wizard :private Heroes
{
public:
Wizard()
{
strength = 15;
HP = 100;
}
~Wizard(){}
friend class Game;
};
class Archer :private Heroes
{
public:
Archer()
{
strength = 25;
HP = 90;
}
~Archer(){}
friend class Game;
};
class Player :private Warrior, Wizard, Archer
{
int HP, strength;
public:
Player(int hp, int strength)
: HP(hp), strength(strength)
{}
~Player(){}
};
menu_functions.cpp
#include <iostream>
#include "headlines.h"
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#define cls system("cls")
using namespace std;
Warrior *war;
Wizard *wiz;
Archer *arch;
void Game::new_game()
{
char choose;
cls;
cout << "Choose your hero!" << endl << endl;
cout << "1. Warrior" << endl;
cout << "2. Wizard" << endl;
cout << "3. Archer" << endl << endl;
cout << "Choose: ";
choose = getch();
switch(choose)
{
case '1':
{
Player user(war -> HP, war -> strength);
}
case '2':
{
Player user(wiz -> HP, wiz -> strength);
}
case '3':
{
Player user(arch -> HP, arch -> strength);
}
}
}
void Game::load_game()
{
}