Making C++ classes available for C

M

Michael Rasmussen

Hi all,

How do you make modules written i C++ available for C?

Until now I have done it this way:

foo.h
class foo {
public:
int bar();
}

foo.cc
int foo::bar()
{
return 1;
}

foo_c.h
int foo_c();

foo_c.cc
#include "foo.h"

foo f;

int foo_c()
{
return f.bar();
}

main.c
#include "foo_c.h"

int main()
{
printf("%d\n", foo_c());
return 0;
}

Any other suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top