C/C++ÄÚ´æ·ÖÅä
#include <iostream>
using namespace std;
void main()
{
char *p,*q;
p = "abcde";
q = p + 3;
*q = 't';
cout<<p<<endl;
cout<<q<<endl;
}
Á½ÖÖÓïÑÔ±àÒ붼¿ÉÒÔͨ¹ý
µ±Ö´Ðе½
*q = 't';
ʱ£¬C++³ÌÐò³öÏÖÄÚ´æ·ÃÎÊ´íÎó£¬C³ÌÐò¿ÉÒÔÔËÐУ¬²¢ÇҰѵÚËĸöÄÚ´æµ¥ÔªÖû»Îªt
C++±àÒëÆ÷ÔÚ±àÒë¹ý³ÌÖУ¬¸ø"abcde"·ÖÅäÁ˳£Á¿ÇøµÄÄÚ´æµ¥Ôª£¬³£Á¿ÇøµÄÄÚ´æµ¥ÔªÔÚÔËÐÐʱÎÞ·¨Ð޸ģ¬Òò´ËÊÔͼ¶Ô³£Á¿ÇøµÄ²Ù×÷»á²úÉúÒì³£¡£
Ïà¹ØÎĵµ£º
²âÊÔ´úÂëÒ»£¨VC6.0¡¢C-code£©£º
#include <stdio.h>
void main()
{
int aa;
unsigned char j1,j2;
aa=j1=j2=0;
aa=49;
j1=aa;
printf("j1=%d \n",j1);
j2=aa;
printf("j2=%c \n",j2);
}
¡¾·ÖÎö¡¿£º
[1]ÕýÈçËùÏëÏóµÄÊä³ö½á¹û£º
j1 ......
.¸ÅÂÛ
¡¡¡¡ÔËÐÐʱ¿âÊdzÌÐòÔÚÔËÐÐʱËùÐèÒªµÄ¿âÎļþ£¬Í¨³£ÔËÐÐʱ¿âÊÇÒÔLIB»òDLLÐÎʽÌṩµÄ¡£
CÔËÐÐʱ¿âµ®ÉúÓÚ20ÊÀ¼Í70Äê´ú£¬µ±Ê±µÄ³ÌÐòÊÀ½ç»¹ºÜµ¥´¿£¬Ó¦ÓóÌÐò¶¼Êǵ¥Ï̵߳ģ¬¶àÈÎÎñ»ò¶àÏ̻߳úÖÆÔÚ´Ëʱ»¹ÊôÓÚйÛÄî¡£ËùÒÔÕâ¸öʱÆÚµÄ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;
}
----------------- ......
¡¡¡¡¶ÔÓÚÒ»¸öc/c++³ÌÐòÔ±À´Ëµ£¬ÄÚ´æй©ÊÇÒ»¸ö³£¼ûµÄÒ²ÊÇÁîÈËÍ·ÌÛµÄÎÊÌâ¡£ÒѾÓÐÐí¶à¼¼Êõ±»Ñо¿³öÀ´ÒÔÓ¦¶ÔÕâ¸öÎÊÌ⣬±ÈÈçSmart Pointer£¬Garbage CollectionµÈ¡£Smart Pointer¼¼Êõ±È½Ï³ÉÊ죬STLÖÐÒѾ°üº¬Ö§³ÖSmart PointerµÄclass£¬µ«ÊÇËüµÄʹÓÃËƺõ²¢²»¹ã·º£¬¶øÇÒËüÒ²²»Äܽâ¾öËùÓеÄÎÊÌ⣻Garbage Collection¼¼ÊõÔÚJavaÖÐ ......