Unexpected end of file, splitting headers into .h/.cpp
Okay I'm trying to split the game class up, and I've been looking online and stuff and I could be doing this horrible wrong, I'll show you guys the .h and .cpp file.
Code:
#ifndef GAME_H
#define GAME_H
#include "Dealer.h"
#include <vector>
#include "IO.H"
#include "Player.h"
class Game
{
public:
Game();
void play_game();
private:
int blackjack(int result) const;
int get_hand_value(vector<Card> hand) const;
int sum;
Player player;
Dealer dealer;
Deck deck;
text_menu tmenu;
IO io;
};
#endif
And this io the CPP file.
Code:
#include "Game.h"
#include <iostream>
Game::Game()
{}
void Game::play_game()
{
//shuffle the deck first
dealer.shuffle_deck(deck);
//draw cards for players
dealer.draw(deck, 1);
player.draw(deck, 2);
//initialize the gameloop
int gameloop = 1;
//initialize output
io.init_output(tmenu);
//start gameloop
while(gameloop != 0)
{
//update
io.update_output(2, dealer.hand->read_cards());
io.update_output(6, player.hand->read_cards());
//display
io.display_output();
gameloop = blackjack(io.get_input());
//clear
io.clear_screen();
}
}
int Game::blackjack(int result)
{
if (result == 1)
{
player.draw(deck, 1);
if (get_hand_value(player.hand->card_list) > 21)
{
return 0;
}
else { return 1; }
}
else if (result == 2)
{
if(get_hand_value(player.hand->card_list ) > get_hand_value(dealer.hand->card_list))
{
return 0;
}
else { return 0; }
}
else if (result == 3)
{
return 0;
}
return 1;
}
int Game::get_hand_value(vector<Card> hand)
{
sum = 0;
for (unsigned int loop = 0; loop < hand.size(); loop++)
{
sum += hand[loop].read_numeric_data();
}
return sum;
}
And idea why im getting an unexpected end of file error at the end of Game.cpp?