C++³ÌÐòµ÷ÓÃCº¯Êý
ÕâÖÖÐèÇóºÜ¶à,ÓÖÒòΪC++ºÍCÊÇÁ½ÖÖÍêÈ«²»Í¬µÄ±àÒëÁ´½Ó´¦Àí·½Ê½,ËùÒÔÒªÉÔ¼Ó´¦Àí.×ܽá´óÖÂÓÐÁ½´óÀàʵÏÖ·½·¨.
ÎÄÖиø³öµÄÊÇÍêÕûµÄ,¾ßÌåµÄ,µ«ÓÖ×î»ù±¾×î¼òµ¥µÄʵÏÖ,ÖÁÓÚÀíÂÛÐԵĶ«Î÷ÔÚÍøÉϺÜÈÝÒ×ËÑË÷µÄµ½.
Ò».ͨ¹ý´¦Àí±»µ÷ÓõÄCÍ·Îļþ
a.h:
#ifndef __A_H
#define __A_H
#ifdef __cplusplus
extern "C" {
#endif
int ThisIsTest(int a, int b);
#ifdef __cplusplus
}
#endif
#endif
a.c:
#include "a.h"
int ThisIsTest(int a, int b) {
return (a + b);
}
aa.h:
class AA {
public:
int bar(int a, int b);
};
aa.cpp:
#include "a.h"
#include "aa.h"
#include "stdio.h"
int AA::bar(int a, int b){
printf("result=%d\n", ThisIsTest(a, b));
return 0;
}
main.cpp:
#include "aa.h"
int main(int argc, char **argv){
int a = 1;
int b = 2;
AA* aa = new AA();
aa->bar(a, b);
delete(aa);
return(0);
}
Makefile:
all:
gcc -Wall -c a.c -o a.o
gcc -Wall -c aa.cpp -o aa.o
gcc -Wall -c main.cpp -o main.o
g++ -o test *.o
¶þ. ͨ¹ý´¦Àíµ÷ÓõÄC++Îļþ
»Ö¸´a.hÎļþΪһ°ãÐÔCÍ·Îļþ,ÔÚaa.cppÎļþÖÐextern°üº¬a.hÍ·Îļþ»òº¯Êý.
a.h:
#ifndef __A_H
#define __A_H
int ThisIsTest(int a, int b);
#endif
aa.cpp:
extern "C"
{
#include "a.h"
}
#include "aa.h"
#include "stdio.h"
int AA::bar(int a, int b){
printf("result=%d\n", ThisIsTest(a, b));
return 0;
}
or
aa.cpp:
#include "aa.h"
#include "stdio.h"
extern "C"
{
int ThisIsTest(int a, int b);
}
int AA::bar(int a, int b){
printf("result=%d\n", ThisIsTest(a, b));
return 0;
}
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch£¨Ê±¼äµã£©£¬clock tick£¨Ê±ÖÓ¼ÆÊ±µ¥Ôª£©
1£®¸ÅÄî
ÔÚC/C++ÖУ¬¶Ô×Ö·û´®µÄ²Ù×÷ÓкܶàÖµµÃ×¢ÒâµÄÎÊÌ⣬ͬÑù£¬C/C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£ÏÂÃæÖ÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨.
ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµ ......
ÔÚANSI CÖУ¬¶ÔÎļþµÄ²Ù×÷·ÖΪÁ½ÖÖ·½Ê½£¬¼´Á÷ʽÎļþ²Ù×÷ºÍI/OÎļþ²Ù×÷£¬ÏÂÃæ¾Í·Ö±ð½éÉÜÖ®¡£
Ò»¡¢Á÷ʽÎļþ²Ù×÷
¡¡¡¡ÕâÖÖ·½Ê½µÄÎļþ²Ù×÷ÓÐÒ»¸öÖØÒªµÄ½á¹¹FILE£¬FILEÔÚstdio.hÖж¨ÒåÈçÏ£º
typedef struct {
int level; /* fill/empty level of buffer */
unsigned flags; /* File status flags */
char fd; /* File des ......
Ö¸ÕëÊÇCµÄÁé»ê£¬ÕýÊÇÖ¸ÕëʹµÃC´æÔÚÁËÕâô¶àÄ꣬¶øÇÒ½«³¤ÆÚ´æÔÚÏÂÈ¥¡£ÊÂʵÉÏ£¬ÎÒ×Ô¼º²»ÓÃCÓïÑÔд³ÌÐòÒѾÓÐÒ»ÄêÁË£¬¹¤×÷ÖнӴ¥µ½µÄÖ»ÓÐjava£¬pythonºÍjavascript.×î½üÓÃCÍê³ÉÁËÒ»ÏÂÀàËÆÓÚOOÖеķâ×°£¨¼´"Àà"£©µÄ¸ÅÄ˳±ã°ÑÖ¸Õ븴ϰÁËÏ£¬¸Ð¾õÓбØÒª¼Çһϡ£
±¾ÎÄÖеÄÀý×ÓÓÐÕâÑùÁ½¸ö¸ÅÄÈÎÎñ£¨Task£© ......