¹ØÓÚC¡¢C++ÖеÄconstºÍÖ¸Õë
żȻµÄÒòËØ£¬¶ÔconstÀ´Á˵ãÐËȤ£¬×öÁËÒ»ÏÂʵÑ飺
1. Óï·¨£ºconst¡¢Ö¸Õë
ÔÚgccÖУ¬ ¶ÔÓÚCÓïÑÔ£¬ÏÂÃæµÄÓï¾äÊǺϷ¨µÄ£º
const int a=0;
int *p=&a;
¶øC++ÖУ¬ÐèÒªÊÖ¹¤Ç¿ÖÆ×ª»»²ÅÄܱàÒëͨ¹ý£º
const int a=0£»
int *p=£¨int *£©&a£»
2. ¼ÈÈ»Äܹ»½«const±äÁ¿µÄµØÖ·¸³¸øÖ¸Ïò·Çconst±äÁ¿µÄÖ¸Õ룬ÄÇôÄÜ·ñ¸Ä±äͨ¹ýÖ¸Õë¸Ä±äconst±äÁ¿µÄֵĨ£¿
1)ÔÚgccÖУ¬±àÒëÖ´ÐÐÒÔÏ´úÂ룺
const int c=2;
int *p=&c;
*p=1;
printf("c is :%d\n",c);
±àÒëʱ»áÓо¯¸æ£º¾¯¸æ£º³õʼ»¯¶ªÆúÁËÖ¸ÕëÄ¿±êÀàÐ͵ÄÏÞ¶¨
½á¹ûΪ£º
c is 1
˵Ã÷ËäÈ»Óо¯¸æ£¬µ«ÊÇ˳Àû±àÒëͨ¹ý£¬²¢Çҳɹ¦¸Ä±äÁ˳£Á¿cµÄÖµ£¨´Ó2±äΪ1£©¡£
2.½ÓÏÂÀ´¿´ÏÂÃæÒ»¶Î´úÂ룺
#include <stdio.h>
#include <unistd.h>
int main(void)
{
const int c=2;
int a=0;
const int *p;
p=&a;
int *p2=&a;
p2[1]=-1;
printf("p2[1] is :%d\n",p2[1]);
printf("a is :%d\n",a);
printf("c is :%d\n",c);
printf("c address is:%d\n",&c);
printf("p2[1] address is:%d\n",p2+1);
printf("*(&c) is :%d\n",*(&c));
}
Õâ¶Î´úÂ룬³ÌÐò»áÓÐÔõÑùµÄÊä³öÄØ£¿
1.±£´æÎªºó׺Ϊ.cµÄÎļþ£¬ÓÃgcc±àÒ룬ִÐнá¹ûÈçÏ£º
p2[1] is :-1
a is :0
c is :-1
c address is:-1076230280
p2[1] address is:-1076230280
*(&c) is :-1
˵Ã÷p2+1µÄµØÖ·ºÍcµÄµØÖ·Ò»Ñù£¬³ÌÐò³É¹¦µÄ¼ä½Ó¸Ä±äÁËcµÄÖµ£¨p2Ô½½ç·ÃÎ
Ïà¹ØÎĵµ£º
ÏÂÔØµÄ°æ±¾ÊÇAxis C++ 1.6 Beta
¿Í»§¶ËºÍ·þÎñÆ÷¶Ë¶¼ÐèҪʵÏÖ°²×°xml½âÎöÆ÷
Xerces C++ (2.2.0)
·þÎñÆ÷¶Ë»¹ÐèÒªapache1.3.x»òÕß2.0.x
Ò»¡¢·þÎñÆ÷¶Ë°²×°
1¡¢°²×°Axis C++
2¡¢°²×°Apache£¬ÎÒÃDzÉÓÃApache 2.2.6
×¢ÒâÒ»¶¨ÒªApache 1.3.x use --enable-module=so; for Apache 2.0.x use --enable-so when configuring£¬± ......
½ñÌìÔÚ¹äÂÛ̳µÄʱºò¿´µ½ÓÐÈ˽ò½òÀÖµÀ£º´ÓC++¸Éµ½×ªÐÍΪjavaÊÇÍ˲½
ÎÒ²»ÈÏΪÊÇÕâÑù£¬Ê×ÏÈÓ¦¸ÃÒ»¸öÈ˵ÄÐËȤ£¬¼ÓÉÏÕâÃÅÓïÑÔ£¬ÕâÃŹ¤×÷ÊÇ·ñ·ûºÏÄã
¸É×Ô¼ºÏ²»¶µÄÓïÑÔ±àÂë²ÅÊÇ×îÖØÒªµÄ£¬µ±È»java±È½ÏÈÝÒ׵㣬ÎÒÒ²ÊÇÕâÑùÈÏΪµÄ
µ«ÊÇjava²¢²»ÊÇ´ó¼ÒËù˵µÄÄÇôÈÝÒ×£¬µ±½ñÉç»á˲»¸Ò˵×Ô¼º»ássh£¬µ±ÊÇ×Ô¼ºÎÊÐÄ×Ô¼ºÑ§µÃÓжàºÃ£¬
ÔÚ ......
[This was posted to comp.lang.c by its author, David Anderson, on 1994-05-06.]
The ``Clockwise/Spiral Rule''
By David Anderson
There is a technique known as the ``Clockwise/Spiral Rule'' which enables any C programmer to parse in their head any C declaration!
There are three simple steps to fo ......
JavaÖе÷ÓÃC/C++Éú³ÉµÄDLL
Ò»¡¢ Éú³ÉCµÄÍ·Îļþ
¡¡¡¡1. ±à¼Main.java
¡¡public class Main
¡¡¡¡{
¡¡¡¡public native static int getStrNum(byte str[], int strLen);
¡¡¡¡}
¡¡¡¡2. Éú³ÉÍ·Îļþ
¡¡¡¡°´win + r´ò¿ª“ÔËÐД´°¿Ú£¬ÊäÈë“cmd”£¬´ò¿ª ......