I have 5 programs that works 100%
I need to integrate them in one code using this code in the main

int A;
cout<<" Enter Your Choice";
  cout<<"1. Algorithm A .";
  cout<<"2. Algorithm B .";
  cout<<"3. Algorithm C";
  cout<<"4. Algorithm D";
  cout<<"5. Algorithm E";
  cin>> A;

 if(A==1)
  {
//call Algorithm A
  }
  else
	  if(A==2)
	  {//call Algorithm B
		  }
		  else
			  if(A==3)
			  {
                              //call Algorithm C
			  }
			  else
				  if(A==4)
				  {//call Algorithm D
				  }
				  else
				    if(A==5)
					{//call Algorithm E
					}


How to Integrate all progrms in one and how to call it using C++?
mybe delete the main from each program, but each one in a class as a function create instance of the class in the main and call the function???

Can any one send me any sample code to solve this out .

Thanks

Thank you for your reply, I need the codes to be in different .cpp files because the indivisual programs is very long, it is not efficient, I need eacch code to be in single .cpp files , any advice how to do it ........... I am searching, working ...any help........

These are basic steps create new project

add Algorithm_A.cpp file

#include <iostream>
#include "Algorithm_A.h"
/*
Calc function
*/
int Algorithm_A::calc(int sum1, int sum2)
{

  //Your custom code here
  std::cout << "Welcome to calc\n";

  int calc = sum1 * sum2;
  std::cout << calc << "\n";


 return 0;
}

add Algorithm_A.h header file

#ifndef ALGORITHM_A_H_INCLUDED
#define ALGORITHM_A_H_INCLUDED

class Algorithm_A
{

	public:
        int calc(int sum1, int sum2);

    private:

    protected:
};

#endif // ALGORITHM_A_H_INCLUDED

then in your main.cpp file

#include <iostream>
#include "Algorithm_A.h"
using namespace std;

int main()
{
    int sum1 = 100;
    int sum2 = 200;

    //Create instance of Algorithm_A class
    Algorithm_A * algorithm_A = new Algorithm_A;
    algorithm_A ->calc(sum1,sum2);
    delete[] algorithm_A;

    return 0;
}

then repeat this process for all your algorithm classes...

This article has been dead for over six months. Start a new discussion instead.