test.c
[cpp]
int call_MyMath_sum (int,int);
int sum(inta , intb) {
return call_MyMath_sum(a,b);
}
int call_MyMath_sum (int,int);
int sum(inta , intb) {
return call_MyMath_sum(a,b);
}
main.cpp
[cpp]
#include <iostream>
using namespace std;
extern"C" {
int sum(int, int);
}
class MyMath {
public:
static int sum(int, int);
};
intMyMath::sum(inta, intb) {
return(a + b);
}
extern"C" int call_MyMath_sum (inta , intb) {
return(MyMath::sum(a,b));
}
int main(void) {
cout<<sum(5,6);
return0;
}
#include <iostream>
using namespace std;
extern"C" {
int sum(int, int);
}
class MyMath {
public:
static int sum(int, int);
};
intMyMath::sum(inta, intb) {
return(a + b);
}
extern"C" int call_MyMath_sum (inta , intb) {
return(MyMath::sum(a,b));
}
int main(void) {
cout<<sum(5,6);
return0;
}
Makefile
[cpp]
main.o:
g++ -c -o main.o main.cpp
test.o:
gcc -c -o test.o test.c
main: main.o test.o
g++ -o main main.o test.o
all: clean main
clean:
rm -f test.o main.o
main.o:
g++ -c -o main.o main.cpp
test.o:
gcc -c -o test.o test.c
main: main.o test.o
g++ -o main main.o test.o
all: clean main
clean:
rm -f test.o main.o