Hi all,
I'm in a C++ course right now and I'm having a bit of trouble getting my virtual function to work correctly. Specifically, trouble with the 2 pointers I have for 2 separate menu displays for my Hangman game.
I have 3 *.h and 3 *.cpp files and the file I'm having trouble in is in MainMenu.cpp. The errors say:
Error - error C2440: 'initializing' : cannot convert from 'Menu *' to 'Controller *' 24
Error - error C2440: 'initializing' : cannot convert from 'HangmanMenu *' to 'Controller *' 25
Also, not sure if the code snippet below that shows my MenuLoop() function will be clear enough for you all to help me out or not without pasting snippets from my other files. If this won't help you in diagnosing my logic errors, I will can paste other parts of the file that I feel is pertinent to my "virtual void display(); function.
#include "MainMenu.h"
#include "HangmanMenu.h"
#include "Controller.h"
#include <iostream>
#include <cctype>
#include <iomanip>
#include <string>
using namespace std;
char selection_new;
Menu::Menu()
{
}
void Menu::MenuLoop()
{
Menu mainMenu; //Declare menu type
HangmanMenu HangMenu; //Declare HangmanMenu type
Controller Ctrl; //Declare controller type
Controller *pCon1 = &mainMenu;
Controller *pCon2 = &HangMenu; //Lines 24-25 points to specific classes and their locations
pCon1->display(); //Access location of MainMenu display
pCon2->display(); //Accesses overridden display function to display HangmanMenu