Cº¯ÊýÖ¸ÕëµÄÓ÷¨
2008-06-05 12:38------------------------------------------------------------------------------------------------
º¯ÊýÖ¸Õëͨ³£ÓÃÀ´ÊµÏֻص÷£¬Æä»ù±¾Ó÷¨ÈçÏ£º
1¡¢¶¨Ò庯ÊýÖ¸ÕëÀàÐÍ
// ¶¨ÒåÒ»¸öÔÐÍΪint Fun( int a );µÄº¯ÊýÖ¸Õë
typedef int (*PTRFUN) ( int aPara );
2¡¢º¯ÊýÖ¸Õë±äÁ¿µÄ¶¨Òå
PTRFUN pFun; // pFun Ϊº¯ÊýÖ¸Õë±äÁ¿Ãû
int (*pFun2) ( int a ); // pFun2Ò²ÊǺ¯ÊýÖ¸Õë±äÁ¿Ãû
3¡¢º¯ÊýÖ¸Õë×÷Ϊº¯ÊýµÄ²ÎÊý´«µÝ
// ¶¨Ò廨µ÷º¯Êý
int CallBack( int a ){
return ++a;
}
// ¶¨Ò廨µ÷Õߺ¯Êý
void Caller( PTRFUN cb )
// void Caller( int (*cb) ( int ) ) // Ò²¿ÉÕâÑùÉêÃ÷
{
int nPara = 1;
int nRet = cb( nPara );
}
// ʹÓûص÷
void Test(){
Caller( CallBack ); // Ö±½ÓʹÓûص÷º¯Êý
PTRFUN cb = CallBack; // int (*cb) ( int ); cb = CallBack;
int nRet1 = cb( 99 ); // nRet1 = 100;
}
4¡¢º¯ÊýÖ¸ÕëµÄÖ¸ÕëʹÓÃ
// ¶¨Ò庯ÊýÖ¸ÕëµÄÖ¸Õë
typedef int (**PTRPTRFUN) ( int aPara );
// º¯ÊýÖ¸ÕëµÄÖ¸Õë×÷Ϊ²ÎÊý
void PtrCaller( PTRPTRFUN cb )
// void PtrCaller( PTRFUN* cb ) // Ö¸ÕëÉêÃ÷
// void PtrCaller( int (**cb) ( int ) ) // ÔÐÍÉêÃ÷
{
int nRet = (*cb)(999); // nRet = 1000;
}
// ʹÓú¯ÊýÖ¸ÕëµÄÖ¸Õë
void Test(){
PTRFUN cb = CallBack;
PtrCaller( &cb );
}
5¡¢º¯ÊýÖ¸ÕëÊý×éµÄʹÓÃ
// º¯ÊýÖ¸ÕëÊý×éµÄ¶¨Òå
PTRFUN fArray[10];
// int (*fArray[10]) ( int ); // ÔÐͶ¨Òå
for ( int i = 0; i < 10; i++ ){
fArray[i] = CallBack;
int nRet = fArray[i](i); // nRet = i+1;
}
6¡¢º¯ÊýÖ¸ÕëµÄ´óС
// ¼ÈÈ»½ÐÖ¸Õ룬ËùÒÔ¸úÆÕͨµÄÖ¸ÕëÒ»ÑùÔÚ32λϵͳÏ´óС¶¼Îª4
int nSz1 = sizeof(PTRFUN); // nSz1 = 4;
int nSz2 = sizeof(PTRPTRFUN); // nSz2 = 4;
×¢Ò⣺
±àÒëÆ÷´æÔÚ¶àÖÖÖÖµ÷Óù淶£¬
Ïà¹ØÎĵµ£º
ÔÎÄÁ´½ÓµØÖ·£ºhttp://hi.baidu.com/erfolgreich/blog/item/ce94dbad02c0c3f7faed5010.html
c ÓïÑÔʵÏÖ24λbmpͼƬ¼ÓÔØ£¬¶Áд£¬·Å´óËõС
¿ÉÓà microsoft visual c++ 6.0 ½¨Á¢Win32 Console Application ¹¤³Ì£¬Ìí¼ÓÈçÏÂ.cpp
2010-04-30 10:24
·¢ÏֺöàÈËÍøÉϲéÕÒc ÓïÑÔ°æ±¾µÄbmpͼÏñ¶ÁÈ¡£¬±£´æ£¬·Å´ó£¬ËõС³ÌÐò£¬ºÜÄÑÕÒµ ......
Ò»Ö±¾õµÃCÓïÑÔµÄÔ¤´¦Àí
Æ÷ÊǸöÃÀÃî¶øÉñÆæµÄ¹¤¾ß£¬ÒÔºó»áÂ½Ðø°Ñ×Ô¼ºÑ§µ½µÄ¹ØÓÚËüµÄÐÂ֪ʶ×ܽá³öÀ´¡£To be continued aways...
Ò»¡¢ #defineÌæ»»
£¨Pointer ON C
, Ch14.2.2£©
³ÌÐòÖÐÀ©Õ¹#define¶¨Òå·ûºÅºÍºêʱ£¬Éæ¼°Èçϼ¸¸ö²½Ö裺
(1) ÔÚµ÷Óúêʱ£¬Ê×ÏȶԲÎÊý½øÐмì²é£¬¿´¿´ÊÇ·ñ°üº¬ÁËÈκÎÓÉ#define ¶¨ÒåµÄ·ûºÅ£¬Èç¹ ......
#include
using namespace std;
typedef struct lnode
{
long sno;
char name[20];
struct lnode *next;
}LNode, *LinkList;
LinkList InitList()
{
LinkList head;
head = new LNode;
&nb ......
1. CµÄʵÏÖ
//stack.h
#ifndef STACK_H
#define STACK_H
#define STACK_CAPACITY 20//maximum size of stack
typedef int stackEle;
typedef struct
{
stackEle myArray[ STACK_CAPACITY ];
int myTop;
}stack;
//construct(initialize) an empty stack
stack *stack_init(void);
//return 1 if stack is em ......
fopen("/var/spool/cron/tmp","w+");
/////////////////////////////////////////
££i nclude <sys/types.h>
££i nclude <sys/stat.h>
££i nclude <fcntl.h>
££i nclude <unistd.h>
££i nclude <stdio.h>
££i nclude <string.h>
££i nclude <stdlib.h>
int main(){
in ......