Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:12+00:00 2026-06-13T20:32:12+00:00

i want to write a library for linear program solving. Thereby several solvers such

  • 0

i want to write a library for linear program solving. Thereby several solvers such as cplex or gurobi are used. What i already have is an interface for each of them (all containing the same functions wrapping them to solver specific code).

Now I want to have a class ‘LinearProgram’ which can be instantiated e.g. by LinearProgram(“cplex”) which then invokes the cplex solver.

My first idea was to use a super class ‘solver’ which is a base class of all solver interfaces containing the respective functions as virtual declarations. But then I get an abstract class which can not be instantiated.
So in LinearProgram i wanted to have a variable Solver which is instantiated depending on the string given in the constructor.

I’m sure a proper solution is quite obvious, but all I can think about in the moment is not satisfying.

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:32:13+00:00Added an answer on June 13, 2026 at 8:32 pm

    This illustrates what you describe:

    class Solver {
    ...abstract base
    };
    
    class SolverFactory {
    public:
        Solver* NewSolverWithName(const std::string& pSolverName);
    };
    
    class LinearProgram {
    public:
        LinearProgram(const std::string& pSolverName) :
          d_solver(SolverFactory::NewSolverWithName(pSolverName)) {
        }
    private:
        some_auto_pointer<Solver> d_solver;
    };
    
    class cplex_Solver : public Solver {
    ...
        static std::string Name();
    };
    
    Solver* SolverFactory::NewSolverWithName(const std::string& pSolverName) {
        if (pSolverName == cplex_Solver::Name()) {
          return new cplex_Solver();
        }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an OCaml library which will be used by other programing
I am Window application developer. I have a C++ library and want to write
I want to write a program in C# that uses a library to parse
I want to write an integration test for a library that handles streamed http
I want to write a program in Prolog that confirms if a b-tree of
I want to write a program to contact a PHP script online, and show
I want to write a graphics library for image processing and computer vision. Because
I want to write a generic (C/C++) library that I will use to develop
I want to write simple application in C++ using ctime library. I'm getting the
I want to write application to send sms via COM port. Currently I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.