[code]
//This is the menu class:
class menu {
public:
string name; //Private variables of class
string choices[5]; //Private variable array
public:
string getName() const; //Public functions of the class, getters and setters
void setMenuName(string n);
string getChoice1() const;
string getChoice2() const;
string getChoice3() const;
string getChoice4() const;
void setChoices(string a, string b, string c, string d); //Function for string array variable
void print();
menu();
menu(string a, string b, string c, string d);
};
//This works fine, does everything I ask it to.
Here is the second class that I want to get the menu class into using composition. I originally had this class working with the menu class via a public inheritance of menu. All I want is the same operation via composition.
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include "Menu.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class Controller
{
public:
menu cMenu;
void Start();
Controller();
private:
};
// This is the start function that used to work, when I was using inheritance:
void Controller::Start()
{
Controller::setMenuName("MENU");
Controller::setChoices("Play Hangman", "Edit Random List", "Check Score", "Exit");
menu::print();
}

New Topic/Question
Reply




MultiQuote





|