Using char and virtual char in my class.. need help!

Posted on 2007-12-01
Last Modified: 2010-04-01
I need help instead of using void for menuDisplay() why would I need to use virtual char? and void for menuChoices() how can I use char instead? I am going to create a class called choices that will handle what the choice returns from BaseMenu. right now I am a little lost please help me!
(This is not a class assignment due !)

Here is my code for BaseMenu.h:
class BaseMenu
      void menuHeader();
      void menuDisplay();
      void menuChoice();
Here is the code for BaseMenu.cpp:
#include <iostream>
#include "basemenu.h"
#include "messages.h"
using namespace std;
char choice;
bool done = false;
Messages mess;
void BaseMenu::menuHeader()
      cout << "******************\n";
      cout << "****** MENU ******\n";
      cout << "******************\n";
void BaseMenu::menuDisplay()
      cout << "***(H)ello     ***\n";
      cout << "***(W)elcome   ***\n";
      cout << "***(O)ther menu***\n";
      cout << "***(Q)uit      ***\n";
      cout << "******************\n";
void BaseMenu::menuChoice()
      cout << "Choice: ";
      cin >> choice;
      cout << endl;
now for SubMenu.h
class SubMenu
      void newMenu();
code in SubMenu.cpp:
#include <iostream>
#include "submenu.h"
#include "basemenu.h"
using namespace std;
BaseMenu bmenu;
void SubMenu::newMenu()
      cout << "***(B)ye       ***\n";
      cout << "***(L)augh     ***\n";
      cout << "***(Q)uit      ***\n";
      cout << "******************\n";

Open in new window

Question by:jschmuff
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20389843
where is the virtual char issue in your code?
You use virtual when you will have a derived class' method with the same name.
LVL 43

Expert Comment

ID: 20390470
Is that what You want(You don't want virtual I guess)
char BaseMenu::menuChoice()
      char c;
      cout << "Choice: ";
      cin >> c;
      cout << endl;
      return c;
LVL 53

Accepted Solution

Infinity08 earned 500 total points
ID: 20390879
See this post of me in one of your other questions :

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ Language error 28 280
C++ :Change value from  DisableCMD registry 4 70
find Speed using GPS latitude & longitude 4 93
boost::uuid crashes 17 40
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question