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 8387655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:16:23+00:00 2026-06-09T18:16:23+00:00

I have 2 projects decoder and dec in my visual studio. One has C

  • 0

I have 2 projects decoder and dec in my visual studio. One has C code and other has C++ code using stl respectively.How do I instantiate the c++ classes in my c code inside decode project?

for e.g.
//instantiating object
reprVectorsTree *r1 = new reprVectorsTree(reprVectors1,8);
//using one of its function
r1->decode(code);

What do I need to do for this?

How do I access files from another project?

How do I make use of existing c++ code in C files?

——–edit———-
I have a class like this

class Node//possible point in our input space
{
public:
    std::vector<float> valuesInDim;//values in dimensions
    std::vector<bool> code;
    Node(std::vector<float>value);
    Node::Node(float x, float y);
Node::Node(std::vector<float> value,std::vector<bool> binary);


};

How do I use the above class in c++?
If C only allows structs how do I map it to a struct?

  • 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-09T18:16:25+00:00Added an answer on June 9, 2026 at 6:16 pm

    Give the C++ module a C interface:

    magic.hpp:

    struct Magic
    {
        Magic(char const *, int);
        double work(int, int);
    };
    

    magic.cpp: (Implement Magic.)

    magic_interface.h:

    struct Magic;
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    typedef Magic * MHandle;
    MHandle create_magic(char const *, int);
    void    free_magic(MHandle);
    double  work_magic(MHandle, int, int);
    
    #ifdef __cplusplus
    }
    #endif
    

    magic_interface.cpp:

    #include "magic_interface.h"
    #include "magic.hpp"
    
    extern "C"
    {
        MHandle create_magic(char const * s, int n) { return new Magic(s, n); }
        void    free_magic(MHandle p) { delete p; }
        double  work_magic(MHandle p, int a, int b) { return p->work(a, b); }
    }
    

    Now a C program can #include "magic_interface.h" and use the code:

    MHandle h = create_magic("Hello", 5);
    double d = work_magic(h, 17, 29);
    free_magic(h);
    

    (You might even want to define MHandle as void * and add casts everywhere so as to avoid declaring struct Magic in the C header at all.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using apache ant in the following way: I have projects P1, P2,
Projects have many tasks and a task has a custom RESTful action called 'approve'.
I have a php script, test.php that has the contents <?php require_once(classes/user.php); echo test;
I have a Visual Studio 2008 C++ project where I need to decode a
I have projects that need to be build with a specific version of the
I'm running wamp on Vista (Apache v2.2.11) and have projects setup such that http://localhost/projectx
C++ projects have a linker option to embed manifest to require UAC elevation (/MANIFESTUAC:level)
I have multiple projects which are to be hosted together in a Tomcat container,
I have two projects: a profiler and a basic application (with JUnit tests) The
I have two projects and I want to combine them together.When I install each

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.