Ò»¸öC++µ÷ÓÃCµÄÀý×Ó
//cExample.h
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
#ifdef __cplusplus
extern "C"
{
#endif
int add(int x, int y);
#ifdef __cplusplus
}
#endif
#endif
---------------------------------
//cExample.c
#include"cExample.h"
int add(int x, int y)
{
return x + y;
}
---------------------------------
//cppFile.cpp
#include <iostream>
#include"cExample.h"
using namespace std;
main()
{
cout<<add(2,3)<<endl;
return 0;
}
--------------------------------
//makefile
cppFile: cppFile.o cExample.o
g++ -g -o cppFile cppFile.o cExample.o
cppFile.o: cppFile.cpp
g++ -g -c cppFile.cpp
cExample.o: cExample.c cExample.h
gcc -g -c cExample.c
clean:
rm -f *.o cppFile
Ïà¹ØÎĵµ£º
¸Ãmakefile Ö»ÊÇÔÚlinux ÖвâÊÔ¹ý£¬ Èô²ÉÓÃhu-ux Ö»ÒªÒÔÏÂmakefileÖеÄgcc ¸ÄΪaCC µ«
hu-ux δ²âÊÔ
1¡¢Ê×ÏÈÈ·¶¨pro*c ¹¤³ÌĿ¼½á¹¹
proc/bin
proc/include
proc/lib
proc/src
src/libsrc
src/project_src
&n ......
1.·Ö²ãÉè¼Æ£¬¸ôÀëÆ½Ì¨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇGUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çÆ½Ì¨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼þÖУ¬ÄÇôÕâ¸öÈí¼þµÄ¿ÉÖ²ÐÔ½«·Ç³£µÄ² ......
ʹÓÃNDK¿ª·¢C/C++ÏîÄ¿¹æÔò
<!-- /* Font Definitions */ @font-face {font-family:ËÎÌå; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;}@font-face {font-family:"\@ËÎÌå&qu ......
1.ÇóÏÂÃæº¯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
int func(x)
{
int countx = 0;
while(x)
{
countx
++;
x = x&(x-1);
}
return countx;
}
¼Ù¶¨x = 9999¡£ ´ð°¸£º8
˼·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓÔҪעÒâÄÄЩÎÊÌ⣿
´ð£ºÒýÓþÍÊÇij¸öÄ¿±ê±äÁ¿µÄ&l ......