Chinaunix首页 | 论坛 | 博客
  • 博客访问: 140681
  • 博文数量: 12
  • 博客积分: 1411
  • 博客等级: 上尉
  • 技术积分: 433
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-25 14:25
文章分类

全部博文(12)

文章存档

2009年(3)

2008年(9)

我的朋友

分类: C/C++

2008-04-10 16:05:57

/*
 *    File : cppExample.h
 */
#ifndef __CPP_EXAMPLE__H__
#define __CPP_EXAMPLE__H__
 
extern "C" int add(int x, int y);
 
#endif
 
===================================================
/*
 *    File : cppExample.cpp
 */
#include "cppExample.h"
 
int add(int x, int y)
{
    return (x + y);
}
 
===================================================
/*
 *    File : cFile.c
 */
#include
 
extern int add(int x, int y);
 
int main(int argc, char **argv)
{
    printf("The value is [%d]\n", add(2, 3));
   
    return 0;
}
 
编译命令:
gcc -o cFile cFile.c cppExample.cpp
 
 
阅读(917) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~