#ifndef ACCOUNT_H_
#define ACCOUNT_H_
#ifdef __cplusplus // 下边的设计就是无论是C 或者 C++ 都可以直接的调用,只需要加上此头文件就可以,
extern "C"
{
#endif
float f(int a, int b);
void p();
void t();
#ifdef __cplusplus
}
#endif
#endif
float f(int a, int b)
{
return a + b;
}
void p()
{
}
void t()
{
}
#include <stdio.h>
#include <stdlib.h>
#include "Account.h"
#include <iostream>
using namespace std;
// float f(int a, int b); // 这个就是函数的定义,此声明在C原因里边调用另外的Account.c 文件里边,
//extern "C" float f(int a, int b); // 这个就可以在C++里边调用Account.c 文件了,C++调用C语言需要在前边加上extern "C"
// 这就是替代链接,这个就是让C++按照C语言的规格去变,
int main()
{
float result;
result = f(10,20);
// printf("%f\n", result);
cout << result << endl;
return 0;
}