Menu

C++ Interface

2024-06-18
2024-06-18
  • Carlos Vazquez de Lara Kallas

    Hello,

    I am currently trying to implement a small example in C++. In the problem_description.hpp the userparam field does not occur. Why is that? Do I have to add it myself? Is there an example completely implemented in C++?

    Thank you!

     
  • Andreas Völz

    Andreas Völz - 2024-06-18

    Dear Carlos,

    in the C++ interface the problem description is implemented as a class and the userparam field is used to store the pointer to the instance of this class. See the code in grampc/cpp/src/problem_description.cpp where the actual probfct interface is implemented. Therefore, userparam is no longer available in the C++ interface. However, it is also no longer necessary since in C++ you can store data in attributes of the class and then access it from all methods. In the C variant this was only possible via global variables or by passing it as userparam to all functions.

    The next version of GRAMPC will include at least one complete C++ example. However, I have attached you a minimal example that at least shows the basic usage. There is a lot that can be done more elegantly in C++ but I have it not available in a form that is ready to share.

    Best regards,
    Andreas Völz

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.