I have a final project for C++ class that requires us to demonstrat each thing that we've learned, a list of 24 things that range from using binary numbers, to loops to passing arrays and polymorphism and recursion.
What I would really like to try is to make a simple demo program of each of these items in independant programs,and let the user choose and run each program from a menu. I don't quite know how to implement this, but I was wondering if I can use namespaces and put each program choice in main in a separate namespace. I also get extra points if I can put all the 24 items in the order they were given, which makes a menu driven program ideal.
Or if there is a better way to implement this sort of design, I'd sure appreciate any input.
Thanks!

I don't think that putting them in separate programs is really what you should do, because that's very weird (and could be challenging a bit).

I think that if you want to pursue your idea of the "24 items into 24 blocks of code", then you should create each item as a header / cpp-file duo (or more). Something like this:

"item1.hpp":

#ifndef MY_PROJECT_ITEM_1_HPP
#define MY_PROJECT_ITEM_1_HPP

void execute_item1();

#endif

"item1.cpp":

#include "item1.hpp"

void execute_item1() {
  // ... code for item 1 (e.g., like the "main()" of your item1 program).
};

"main.cpp":

#include "item1.hpp"
#include "item2.hpp"
#include "item3.hpp"
...

int main() {

  while(true) {
    int item_chosen = 0;
    std::cout << "Please enter item to execute: ";
    std::cin >> item_chosen;

    switch(item_chosen) {
      case 0:
        return 0;
      case 1:
        execute_item1();
        break;
      case 2:

      ...

      default:
        std::cerr << "Error, invalid choice!" << std::endl;
    };
  };

};

Then you just compile all your cpp files and linked them together. That's the "C++ way" of doing things.

Also, I would note that I doubt that your professor really just wants you to copy-paste your last 24 assignments into a single project. There isn't much "learning" involved in doing that. My guess is that he wants you to come up with a more complete and coherent project that happens to exercise all of your learned skills. That's just something to think about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.