(ת)Ò»¸ö¼òµ¥µÄ´øÍ·Î²Ö¸Õëµ¥ÏòÁ´±í£¨CʵÏÖ£©
ÓÃCдÁËÒ»¸ö´øÍ·Î²Ö¸ÕëµÄµ¥ÏòÁ´±í£¬½öÔÚβ²¿½øÐвåÈë²Ù×÷£¬ÔÚÈÎÒâλÖýøÐÐɾ³ý²Ù×÷¡£ÒòΪֻÓõ½ÕâôЩ¹¦ÄÜ£¬ÓÖÒòΪÀÁ£¬ËùÒÔûÓÐÀ©Õ¹¡£ÒòΪ²åÈëÊǹ̶¨ÔÚβ²¿½øÐУ¬´øÒ»¸öβָÕëµÄºÃ´¦ÊÇÏÔ¶øÒ×¼ûµÄ¡£µ±È»É¾³ýʱҪ¸¶³öһЩ¿ªÏú¡£
¡¡¡¡list.h
¡¡¡¡£££££££££££££££££££££££££££££££££££££££££££
¡¡¡¡/* list.h
¡¡¡¡** Copyright 2004 Coon Xu.
¡¡¡¡** Author: Coon Xu
¡¡¡¡** Date: 06 Sep 2004
¡¡¡¡*/
¡¡¡¡#ifndef LIST_H
¡¡¡¡#define LIST_H
¡¡¡¡#include <stdio.h>
¡¡¡¡#include <stdlib.h>
¡¡¡¡struct listnode
¡¡¡¡{
¡¡¡¡ struct listnode* next;
¡¡¡¡ int data;
¡¡¡¡};
¡¡¡¡struct list
¡¡¡¡{
¡¡¡¡ struct listnode* head;
¡¡¡¡ struct listnode* tail;
¡¡¡¡ int count;
¡¡¡¡};
¡¡¡¡void list_init(struct list*);
¡¡¡¡void list_insert(struct list*, struct listnode*);
¡¡¡¡int list_delete(struct list*, struct listnode*);
¡¡¡¡#endif
¡¡¡¡££££££££££££££££££££££££££££££££££££££££££
¡¡¡¡list.c
¡¡¡¡££££££££££££££££££££££££££££££££££££££££££
¡¡¡¡/* list.c
¡¡¡¡** Copyright 2004 Coon Xu.
¡¡¡¡** Author: Coon Xu
¡¡¡¡** Date: 06 Sep 2004
¡¡¡¡*/
¡¡¡¡#include "list.h"
¡¡¡¡void list_init(struct list* myroot)
¡¡¡¡{
¡¡¡¡ myroot->count = 0;
¡¡¡¡ myroot->head = NULL;
¡¡¡¡ myroot->tail = NULL;
¡¡¡¡}
¡¡¡¡void list_insert(struct list* myroot, struct listnode* mylistnode)
¡¡¡¡{
¡¡¡¡ myroot->count++;
¡¡¡¡
¡¡¡¡ mylistnode->next = NULL;
¡¡¡¡ if(myroot->head == NULL)
¡¡¡¡ {
¡¡¡¡ myroot->head = mylistnode;
¡¡¡¡ myroot->tail = mylistnode;
¡¡¡¡ }
¡¡¡¡ else
¡¡¡¡ {
¡¡¡¡ myroot->tail->next = mylistnode;
¡¡¡¡ myroot->tail = mylistnode;
¡¡¡¡ }
¡¡¡¡}
¡¡¡¡int list_delete(struct list* myroot, struct listnode* mylistnode)
¡¡¡¡{
¡¡¡¡ struct listnode* p_listnode = myroot->head;
¡¡¡¡ struct listnode* pre_listnode;
¡¡¡¡
¡¡¡¡ //myroot is empty
¡¡¡¡ if(p_listnode == NULL)
¡¡¡¡ {
¡¡¡¡ return 0;
¡¡¡¡ }
¡¡¡¡
¡¡¡¡ if(p_listnode =
Ïà¹ØÎĵµ£º
ʲôÊÇ¿ÕÖ¸Õë³£Á¿£¨null pointer constant£©?
[6.3.2.3-3] An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.
ÕâÀï¸æËßÎÒÃÇ£º0¡¢0L¡¢'\0'¡¢3 - 3¡¢0 * 17 £¨ËüÃǶ¼ÊÇ“integer constant expression”£©ÒÔ¼° (void*)0 µÈ¶¼ÊÇ¿Õ ......
Èç¹ûC++µ÷ÓÃÒ»¸öCÓïÑÔ±àдµÄ.DLLʱ£¬µ±°üÀ¨.DLLµÄÍ·Îļþ»òÉùÃ÷½Ó¿Úº¯Êýʱ£¬Ó¦¼Óextern "C" {¡¡}¡£
È磺
Í·ÎļþcExample.h
#include <stdio.h>
#ifndef C_EXAMPLE_H
#define C_EXAMPLE_H
int add(int x,int y);
#endif
º¯ÊýʵÏÖÎļþcExample.c(×¢ÒâÊÇ.cÎļþ)
#include<stdio.h>
#include "cExample ......
µ¥Àýģʽ£º¶ÔÓ¦Ò»¸öÀàÖ»ÄÜÉú³ÉÒ»¸ö¶ÔÏó¡£
#include <stdio.h>
class A
{
private:
int id;
A() {}//°Ñ¹¹Ô캯Êý·ÅÔÚprivate£ºÏÂÄ¿µÄÊÇÔÚÀàÍâ²»ÄÜÔÚÕ»ÉÏÖ±½Ó·ÖÅä¿Õ¼ä¶¨Òå¶ÔÏó¡£
public:
static A *pt;
static A *instance()
  ......
×î½üʵÔÚÊÇ̫æÁË£¬ÕâÆªÕûÕû¾ÍÍÆ³ÙÁË1¸öÔÂÁË£¬ÊµÔÚÊǶԲ»Æð¡£Ö®Ç°±¾´òËãÕâ¸öÄ£¿é¾Í½áÊøÁË£¬Îļþ²Ù×÷¾Í²»Ð´ÁË£¬µ«ÊÇÎļþ²Ù×÷ÓÖÊÇÒ»¸öºÜÖØÒªµÄ¶«Î÷£¬¶øÇÒÒ²¸ÕºÃÄܹ»×ܽá֮ǰÎÒÃÇѧϰµÄËùÓÐ֪ʶ¡£Í¬Ê±Ò²ÎªÁ˽«Îļþ²Ù×÷Õâ¸ö³õѧÕßÈÏΪºÜÉñÃØµÄ¶«Î÷¸ø±¾ÖÊ»¯¡£Òò´Ë£¬±¾Æª½«ÖðÒ»½éÉÜCÓïÑÔµÄÎļþ²Ù×÷¡££¨±¾Ä£¿éµÄÃüÃû±¾À´ÊÇÏëC\C++Ò ......