#include#include #include #include "cmenu.h" using namespace std; int main() { CMenu mainMenu("Main Menu"); mainMenu.AddItem("Option 1"); mainMenu.AddItem("Option 2"); while (1) { system("cls"); mainMenu.Display(); int choice = getch(); if (choice == '1') { cout << "You selected Option 1." << endl; } else if (choice == '2') { cout << "You selected Option 2." << endl; } cout << "Press any key to continue..." << endl; getch(); } return 0; }
#includeThe package library for CMenu is the C++ Standard Library.#include #include #include "cmenu.h" using namespace std; int main() { CMenu colorMenu("Font Color Menu"); colorMenu.AddItem("Red", []() {system("color 04");}); colorMenu.AddItem("Green", []() {system("color 02");}); colorMenu.AddItem("Blue", []() {system("color 01");}); CMenu mainMenu("Main Menu"); mainMenu.AddItem("Change Font Color", [&](){colorMenu.Display();}); mainMenu.AddItem("Exit", [](){exit(0);}); while (1) { system("cls"); mainMenu.Display(); int choice = getch(); if (choice == '2') { break; } } return 0; }