Cº¯ÊýÖ¸Õë×ܽá
±¾ÎĽöÏÞÓÚC£¬Ö÷Òª×Ô¼ºÀÏÍü¡£±ðµÄ·Ï»°ÉÙ˵¡£
1.Basic
Ê×ÏÈ¿¼ÂǺ¯ÊýÔÚº¯ÊýÌåÄڵĶ¨Ò壬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
printf("%d\n", add(1,3));
printf("%d\n", def(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
¶¨ÒåÒ»¸öº¯ÊýÖ¸Õ룺
ReturnValue (*fun_ptr)();
ÉÏÃæµÄ´úÂëÓú¯ÊýÖ¸ÕëµôÓÃÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int main()
{
int add(int,int);
int def(int, int);
int (*p)();
p = add;
printf("%d\n", p(1,3));
p = def;
printf("%d\n", p(3,1));
return 0;
}
int add(int a, int b) { return a+b; }
int def(int a, int b) { return a-b; }
µ½´ËΪֹòËÆûÓÐʲôÓ㬲»¹ý¿ÉÒÔ¿¼ÂÇÒ»¸ö¸ü¼Ó¾ßÓÐÃÀ¸ÐµÄд·¨£¬ÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
typedef struct FuncPtrEle
{
int (*fun_ptr)();
int type_code;
} ptr_t;
int add(int,int);
int def(int, int);
int main()
{
int i = 0;
ptr_t ptr_array[2];
ptr_array[0].fun_ptr = add; //ÕâÁ½Ö¸Õ븳ֵµÄ¹ý³Ì¿ÉÒÔÈÎÒâ·¢»ÓÏëÏóÁ¦¡£
ptr_array[1].fun_ptr = def; //ÖÁÓÚ×÷Óã¬ÏëÏëÃæÏò¶ÔÏóÖеĶà̬°É....
for(i = 0; i < 2; i++)
{
printf("%d\n", ptr_array[i].fun_ptr(3,1));
}
return 0;
}
int add(int a, int b) { ret
Ïà¹ØÎĵµ£º
http://www.devdiv.net/blog/space-14481-do-blog-id-458.html
ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏֵġ£ClientÊÇÀûÓÃServerÌṩµÄÌض¨· ......
¡¡¡¡Ëùν“Îļþ”ÊÇÖ¸Ò»×éÏà¹ØÊý¾ÝµÄÓÐÐò¼¯ºÏ¡£ Õâ¸öÊý¾Ý¼¯ÓÐÒ»¸öÃû³Æ£¬½Ð×öÎļþÃû¡£ ʵ¼ÊÉÏÔÚÇ°ÃæµÄ¸÷ÕÂÖÐÎÒÃÇÒѾ¶à´ÎʹÓÃÁËÎļþ£¬ÀýÈçÔ´³ÌÐòÎļþ¡¢Ä¿±êÎļþ¡¢¿ÉÖ´ÐÐÎļþ¡¢¿âÎļþ (Í·Îļþ)µÈ¡£Îļþͨ³£ÊÇפÁôÔÚÍⲿ½éÖÊ(Èç´ÅÅ̵È)Éϵģ¬ ÔÚʹÓÃʱ²Åµ÷ÈëÄÚ´æÖÐÀ´¡£´Ó²»Í¬µÄ½Ç¶È¿É¶ÔÎļþ×÷²»Í¬µÄ·ÖÀà¡£´ÓÓû ......
±àÒëNative CµÄhello,worldÄ£¿é
Android ±àÒë»·¾³±¾Éí±È½Ï¸´ÔÓ£¬ÇÒ²»ÏñÆÕͨµÄ±àÒë»·¾³£ºÖ»Óж¥²ãĿ¼Ï²ÅÓÐMakefileÎļþ£¬¶øÆäËûµÄÿ¸öcomponent¶¼Ê¹ÓÃͳһ±ê×¼µÄ Android.mk. Android.mkÎļþ±¾ÉíÊDZȽϼòµ¥µÄ£¬²»¹ýËü²¢²»ÊÇÎÒÃÇÊìϤµÄMakefile£¬¶øÊǾ¹ýÁËAndroid×ÔÉí±àÒëϵͳµÄºÜ¶à´¦Àí£¬Òò´ËÒªÕæÕýÀ ......
cÔËÐпâmalloc·ÖÅäµÄÄÚ´æÔÚÄÄÀïÄØ£¬Ê×ÏÈÉÏ´úÂ룺
//ÄÚ´æ´óСÁ¬½ÓÆ÷½«ÆäµØÖ·Ö¸Ïò-heapÑ¡Ïî
extern _DATA_ACCESS int _SYSMEM_SIZE;
//ÄÚ´æÇøÓò
#pragma DATA_SECTION(_sys_memory, ".sysmem")
far PACKET _sys_memory[1] = { ((size_t)&_SYSMEM_SIZE) - sizeof(PACKET), 0 };
  ......
Ò»¸öÓÉC/C++±àÒëµÄ³ÌÐòÕ¼ÓõÄÄÚ´æ·ÖΪÒÔϼ¸¸ö²¿·Ö
1¡¢Õ»Çø£¨stack£©— ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å
£¬´æ·Åº¯ÊýµÄ²ÎÊýÖµ£¬¾Ö²¿±äÁ¿µÄÖµµÈ¡£Æä²Ù×÷·½Ê½ÀàËÆÓÚÊý¾Ý½á¹¹ÖеÄÕ»¡£
2¡¢¶ÑÇø£¨heap£© — Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å
£¬
Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøʱ¿ÉÄÜÓÉOS»ØÊÕ ¡£×¢ÒâËüÓëÊý¾Ý½á¹¹ÖеĶÑÊÇÁ½»ØÊ£¬·ÖÅä·½ ......