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;
}
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
&n ......
Ç°¼¸ÌìдÁ˹ØÓÚKeilÓëC/C++»ìºÏ±à³ÌµÄÈô¸ÉÎÊÌ⣬½ñÌìдµÄÊǼÌÐøÇ°ÃæµÄ¡£
ÔÚʹÓÃC/C++»ìºÏ±à³ÌµÄʱºò£¬³ÌÐòÔËÐе½ÀàÀïÃæµÄÐéÄ⺯ÊýʱËÀµô£¬²é¿´ÆävptrֵΪ0x00000000£¬Õâʱºò²»ÖªµÀÔõô½â¾ö£¬ºóÀ´×Ô¼º±àÁËÒ»¸öʵÀý³ÌÐò¿ÉÒÔͨ¹ý£¬·¢ÏÖvptrµÄÖµÊÇÔÚ__mainÀïÃæµÄ& ......
Ö¸ÕëÊÇCµÄÁé»ê£¬ÕýÊÇÖ¸ÕëʹµÃC´æÔÚÁËÕâô¶àÄ꣬¶øÇÒ½«³¤ÆÚ´æÔÚÏÂÈ¥¡£ÊÂʵÉÏ£¬ÎÒ×Ô¼º²»ÓÃCÓïÑÔд³ÌÐòÒѾÓÐÒ»ÄêÁË£¬¹¤×÷ÖнӴ¥µ½µÄÖ»ÓÐjava£¬pythonºÍjavascript.×î½üÓÃCÍê³ÉÁËÒ»ÏÂÀàËÆÓÚOOÖеķâ×°£¨¼´"Àà"£©µÄ¸ÅÄ˳±ã°ÑÖ¸Õ븴ϰÁËÏ£¬¸Ð¾õÓбØÒª¼Çһϡ£
±¾ÎÄÖеÄÀý×ÓÓÐÕâÑùÁ½¸ö¸ÅÄÈÎÎñ£¨Task£© ......
CÓïÑÔÖпɱä²ÎÊýµÄÓ÷¨
ÎÒÃÇÔÚCÓïÑÔ±à³ÌÖлáÓöµ½Ò»Ð©²ÎÊý¸öÊý¿É±äµÄº¯Êý,ÀýÈçprintf()
Õâ¸öº¯Êý,ËüµÄ¶¨ÒåÊÇÕâÑùµÄ:
int printf( const char* format, ...);
Ëü³ýÁËÓÐÒ»¸ö²ÎÊýformat¹Ì¶¨ÒÔÍâ,ºóÃæ¸úµÄ²ÎÊýµÄ¸öÊýºÍÀàÐÍÊÇ
¿É±äµÄ,ÀýÈçÎÒÃÇ¿ÉÒÔÓÐÒÔϲ»Í¬µÄµ÷Ó÷½·¨:
printf("%d",i);
printf("%s",s);
printf( ......
CEO
CEO£¨Chief Executive Officer£©£¬¼´Ê×ϯִÐй٣¬ÊÇÃÀ¹úÈËÔÚ20ÊÀ¼Í60Äê´ú½øÐй«Ë¾ÖÎÀí½á¹¹¸Ä¸ï´´ÐÂʱµÄ²úÎËüµÄ³öÏÖÔÚijÖÖÒâÒåÉÏ´ú±í׎«ÔÀ´¶Ê»áÊÖÖеÄһЩ¾ö²ßȨ¹ý¶Éµ½¾Óª²ãÊÖÖС£
ÔÚÎÒ¹ú£¬CEOÕâ¸ö¸ÅÄî×îÔç³öÏÖÔÚһЩÍøÂçÆóÒµÖС£ÔÚÄÇÀCEOÍùÍùÊÇ×Ô·âµÄ£¬Ò²ºÜÉÙÓÐÈËÈ¥Ñо¿ÕâÒ»³Æν¶ÔÆóÒµµ½µ×Òâζ×Åʲô¡£µ ......