50¸öc/c++Ô´´úÂëÍøÕ¾
ÎÄÕ³ö´¦£ºhttp://blog.chinaunix.net/u3/106835/showart_2190632.html
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë
¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨
Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/
--ÊýÒÔǧ¼ÆµÄÓÐÓõÄCÓïÑÔÔ´´úÂëƬ¶Î
2¡¢http://www.hotscripts.com/category/c-cpp/scripts-programs/
Hotscripts --ÌṩÊýÒ԰ټƵÄCºÍC++½Å±¾ºÍ³ÌÐò¡£ËùÓгÌÐò¶¼·ÖΪ²»Í¬µÄÀà±ð¡£
3¡¢http://www.planetsourcecode.com/vb/default.asp?lngWId=3
--³¬¹ýÍòÐÐCºÍC++Ãâ·ÑµÄÔ´´úÂë
4¡¢http://freshmeat.net/browse/164/
--³¬¹ý9000¸öC±àдµÄÏîÄ¿¡£
5¡¢http://www.daniweb.com/code/c.html
--DANIWEBÌṩµÄʵÓôúÂë¶Î ¡£
6¡¢http://www.programmersheaven.com/tags/C/
--programmersheaven.comÉϵÄC±à³Ì×ÊÔ´¡£
7¡¢http://www.ddj.com/code/ddj.html
--Dr. Dobb’s JournalµÄÔ´´úÂë¡£
8¡¢http://www.cprogramming.com/cgi-bin/source/ ......
50¸öc/c++Ô´´úÂëÍøÕ¾
ÎÄÕ³ö´¦£ºhttp://blog.chinaunix.net/u3/106835/showart_2190632.html
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë
¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨
Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/
--ÊýÒÔǧ¼ÆµÄÓÐÓõÄCÓïÑÔÔ´´úÂëƬ¶Î
2¡¢http://www.hotscripts.com/category/c-cpp/scripts-programs/
Hotscripts --ÌṩÊýÒ԰ټƵÄCºÍC++½Å±¾ºÍ³ÌÐò¡£ËùÓгÌÐò¶¼·ÖΪ²»Í¬µÄÀà±ð¡£
3¡¢http://www.planetsourcecode.com/vb/default.asp?lngWId=3
--³¬¹ýÍòÐÐCºÍC++Ãâ·ÑµÄÔ´´úÂë
4¡¢http://freshmeat.net/browse/164/
--³¬¹ý9000¸öC±àдµÄÏîÄ¿¡£
5¡¢http://www.daniweb.com/code/c.html
--DANIWEBÌṩµÄʵÓôúÂë¶Î ¡£
6¡¢http://www.programmersheaven.com/tags/C/
--programmersheaven.comÉϵÄC±à³Ì×ÊÔ´¡£
7¡¢http://www.ddj.com/code/ddj.html
--Dr. Dobb’s JournalµÄÔ´´úÂë¡£
8¡¢http://www.cprogramming.com/cgi-bin/source/ ......
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// º¯ÊýµÄÖØÔØ,ÕâÑùµÄÖØÔØ·½Ê½,ÔÚJavaÖÐÄÜÐÐ,ÔÚC/C++ÖÐÈ´²»ÐÐ
virtual void fn(float x) {
cout << "In SubClass, float x = " << x << endl;
}
};
void test(Base& b) {
int i = 1;
b.fn(i);
float f = 2.0;
b.fn(f);
}
int main() {
Base bc;
SubClass sc;
cout << "Calling test(bc)\n";
test(bc);
cout << "Calling test(sc)\n";
test(sc);
return 0;
}
Calling test(bc)
In Base class, int x = 1
In Base class, int x = 2
Calling test(sc)
In Base class, int x = 1
In Base class, int x = 2
ÔËÐгɹ¦£¨×ܼÆʱ¼ä£º 312ºÁÃ룩
×¢Òâ,¶¼Êǵ÷Óõĸ¸ÀàÖеĺ¯Êý.
package cn.vicky;
public class MyTest {
public void add(int i) {
System.out.println("in parent");
}
public ......
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// º¯ÊýµÄÖØÔØ,ÕâÑùµÄÖØÔØ·½Ê½,ÔÚJavaÖÐÄÜÐÐ,ÔÚC/C++ÖÐÈ´²»ÐÐ
virtual void fn(float x) {
cout << "In SubClass, float x = " << x << endl;
}
};
void test(Base& b) {
int i = 1;
b.fn(i);
float f = 2.0;
b.fn(f);
}
int main() {
Base bc;
SubClass sc;
cout << "Calling test(bc)\n";
test(bc);
cout << "Calling test(sc)\n";
test(sc);
return 0;
}
Calling test(bc)
In Base class, int x = 1
In Base class, int x = 2
Calling test(sc)
In Base class, int x = 1
In Base class, int x = 2
ÔËÐгɹ¦£¨×ܼÆʱ¼ä£º 312ºÁÃ룩
×¢Òâ,¶¼Êǵ÷Óõĸ¸ÀàÖеĺ¯Êý.
package cn.vicky;
public class MyTest {
public void add(int i) {
System.out.println("in parent");
}
public ......
#include <iostream>
using namespace std;
class Base {
public:
virtual void fn(int x) {
cout << "In Base class, int x = " << x << endl;
}
};
class SubClass : public Base {
public:
// º¯ÊýµÄÖØÔØ,ÕâÑùµÄÖØÔØ·½Ê½,ÔÚJavaÖÐÄÜÐÐ,ÔÚC/C++ÖÐÈ´²»ÐÐ
virtual void fn(float x) {
cout << "In SubClass, float x = " << x << endl;
}
};
void test(Base& b) {
int i = 1;
b.fn(i);
float f = 2.0;
b.fn(f);
}
int main() {
Base bc;
SubClass sc;
cout << "Calling test(bc)\n";
test(bc);
cout << "Calling test(sc)\n";
test(sc);
return 0;
}
Calling test(bc)
In Base class, int x = 1
In Base class, int x = 2
Calling test(sc)
In Base class, int x = 1
In Base class, int x = 2
ÔËÐгɹ¦£¨×ܼÆʱ¼ä£º 312ºÁÃ룩
×¢Òâ,¶¼Êǵ÷Óõĸ¸ÀàÖеĺ¯Êý.
package cn.vicky;
public class MyTest {
public void add(int i) {
System.out.println("in parent");
}
public ......
LinuxϽøÐÐMYSQLµÄC++±à³ÌÆð²½ÊÖ¼Ç
Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
nano test.cpp
ÊäÈëÄÚÈÝ
#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
mysql_init(&mysql);
}
ctrl+O±£´æctrl+xÍ˳ö¡£
È»ºó±àÒë
g++ -lmysqlclient test.cpp -o test
ÔËÐÐ
./test
Èç¹ûʲô¶¼Ã»Ìáʾ£¬Ã»´íÎ󣬾Í˵Ã÷³É¹¦ÁË¡£
¾ÍÊÇÕâÑù¡£¶÷¡£»¹ÊÇÂú¡£¡£¡£¼òµ¥µÄ˵¡£
......
LinuxϽøÐÐMYSQLµÄC++±à³ÌÆð²½ÊÖ¼Ç
Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
nano test.cpp
ÊäÈëÄÚÈÝ
#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
mysql_init(&mysql);
}
ctrl+O±£´æctrl+xÍ˳ö¡£
È»ºó±àÒë
g++ -lmysqlclient test.cpp -o test
ÔËÐÐ
./test
Èç¹ûʲô¶¼Ã»Ìáʾ£¬Ã»´íÎ󣬾Í˵Ã÷³É¹¦ÁË¡£
¾ÍÊÇÕâÑù¡£¶÷¡£»¹ÊÇÂú¡£¡£¡£¼òµ¥µÄ˵¡£
......
LinuxϽøÐÐMYSQLµÄC++±à³ÌÆð²½ÊÖ¼Ç
Ê×ÏÈ°²×°±ØÐèµÄ¿ª·¢°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
nano test.cpp
ÊäÈëÄÚÈÝ
#include <stdio.h>
#include <stdlib.h>
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
mysql_init(&mysql);
}
ctrl+O±£´æctrl+xÍ˳ö¡£
È»ºó±àÒë
g++ -lmysqlclient test.cpp -o test
ÔËÐÐ
./test
Èç¹ûʲô¶¼Ã»Ìáʾ£¬Ã»´íÎ󣬾Í˵Ã÷³É¹¦ÁË¡£
¾ÍÊÇÕâÑù¡£¶÷¡£»¹ÊÇÂú¡£¡£¡£¼òµ¥µÄ˵¡£
......
ÉÏÒ»´ÎÓÃlinuxÊÇ2002ÄêÓÃkdevelop¼°qt¿â¿ª·¢¶àýÌåÈí¼þ¡£
ʱ¸ô8ÄêÔÙÒ»´ÎÔÚlinuxϸ㿪·¢£¬ÒÀÈ»²ËÄñ£¬»¹ÊÇÉúÊè¡£
¸Ð¾õ×Ô¼ºµÄ´óÄԵĴ洢¿Õ¼ä£¬Ëæ×ÅÄêÁäµÄÔö¼ÓÔÚ±äС£¬ºÜ¶àŪ¹ýµÄ£¬ÓÖÖ»ÄÜ´ÓͷѧÆð¡£
²»¹ýÓо仰“»îµ½ÀÏ£¬Ñ§µ½ÀÏ”¹þ£¡
²ÑÀ¢£¬²ÑÀ¢¡£
1¡¢±àд¶¯Ì¬¿âµÄc++Îļþ
cvpnlib.cpp cvpnlib.h
2¡¢±àÒë³É¶¯Ì¬¿â
g++ -c -fPIC cvpnlib.cpp
g++ -shared -fPIC -o libvpnlib.so cvpnlib.o
3¡¢±àдµ÷ÓõĶ¯Ì¬¿âµÄ¿ØÖÆ̨³ÌÐòÎļþ
main.cpp
4¡¢±àÒë¿ØÖÆ̨³ÌÐò
g++ -c main.cpp
g++ -o main main.o -L. -lvpnlib
5¡¢¿½±´libvpnlib.soÎļþµ½/usr/libĿ¼ÏÂ
6¡¢ÔËÐÐ./main ......
ÉÏÒ»´ÎÓÃlinuxÊÇ2002ÄêÓÃkdevelop¼°qt¿â¿ª·¢¶àýÌåÈí¼þ¡£
ʱ¸ô8ÄêÔÙÒ»´ÎÔÚlinuxϸ㿪·¢£¬ÒÀÈ»²ËÄñ£¬»¹ÊÇÉúÊè¡£
¸Ð¾õ×Ô¼ºµÄ´óÄԵĴ洢¿Õ¼ä£¬Ëæ×ÅÄêÁäµÄÔö¼ÓÔÚ±äС£¬ºÜ¶àŪ¹ýµÄ£¬ÓÖÖ»ÄÜ´ÓͷѧÆð¡£
²»¹ýÓо仰“»îµ½ÀÏ£¬Ñ§µ½ÀÏ”¹þ£¡
²ÑÀ¢£¬²ÑÀ¢¡£
1¡¢±àд¶¯Ì¬¿âµÄc++Îļþ
cvpnlib.cpp cvpnlib.h
2¡¢±àÒë³É¶¯Ì¬¿â
g++ -c -fPIC cvpnlib.cpp
g++ -shared -fPIC -o libvpnlib.so cvpnlib.o
3¡¢±àдµ÷ÓõĶ¯Ì¬¿âµÄ¿ØÖÆ̨³ÌÐòÎļþ
main.cpp
4¡¢±àÒë¿ØÖÆ̨³ÌÐò
g++ -c main.cpp
g++ -o main main.o -L. -lvpnlib
5¡¢¿½±´libvpnlib.soÎļþµ½/usr/libĿ¼ÏÂ
6¡¢ÔËÐÐ./main ......
/*
* test.cpp
*
* Created on: 2010-5-13
* Author: Sarah
*/
#include "/usr/include/mysql/mysql.h" /*Ϊ¾ø¶Ô·¾¶*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;
int main(int argc,char *argv[])
{
char *user = "root", *pwd = "475475", *dbname = "bookman";
MYSQL mysql;
MYSQL_RES *mysql_ret;
MYSQL_ROW mysql_row;
unsigned long num_rows;
int ret;
mysql_init(&mysql);
if(mysql_real_connect(&mysql,NULL,user,pwd,dbname,0,NULL,0))
{
printf("C ......
1.·Ö²ãÉè¼Æ£¬¸ôÀëƽ̨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇGUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çƽ̨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼þÖУ¬ÄÇôÕâ¸öÈí¼þµÄ¿ÉÖ²ÐÔ½«·Ç³£µÄ²î£¬ÕâÊDz»ÑÔ×ÔÃ÷µÄ¡£ÄÇôÈçºÎ±ÜÃâÕâÖÖÇé¿öÄØ£¿µ±È»ÊÇ·Ö²ãÉè¼ÆÁË£º
¡¡¡¡×îµ×²ã²ÉÓÃAdapterģʽ£¬°Ñ²»Í¬²Ù×÷ϵͳµÄAPI·â×°³ÉÒ»Ì×ͳһµÄ½Ó¿Ú¡£ÖÁÓÚ·â×°³ÉÀ໹ÊÇ·â×°³Éº¯Êý£¬Òª¿´Äã²ÉÓõÄC»¹ÊÇC++дµÄ³ÌÐòÁË¡£Õâ¿´ÆðÀ´ºÜ¼òµ¥£¬Æäʵ²»¾¡È»£¨¿´ÍêÕûƪÎÄÕºóÄã»áÃ÷°×µÄ£©£¬Ëü½«ºÄÈ¥Äã´óÁ¿µÄʱ¼äÈ¥±àд´úÂ룬ȥ²âÊÔËüÃÇ¡£²ÉÓÃÏÖ´æµÄ³ÌÐò¿â£¬ÊÇÃ÷ÖǵÄ×ö·¨£¬ÓкܶàÕâÑùµÄ¿â£¬±ÈÈ磬C¿âÓÐglib£¨GNOMEµÄ»ù´¡Àࣩ£¬C++¿âÓÐACE(ADAPTIVE Communication Environment)µÈµÈ£¬ÔÚ¿ª·¢µÚÒ»¸öƽ̨ʱ¾Í²ÉÓÃÕâЩ¿â£¬¿ÉÒÔ´ó´ó¼õÉÙÒÆÖ²µÄ¹¤×÷Á¿¡£
¡¡¡¡×îÉϲã²ÉÓÃMVCÄ£ÐÍ£¬·ÖÀë½çÃæ±íÏÖÓëÄÚ²¿Âß¼´úÂë¡£°Ñ´ó²¿·Ö´úÂë·Åµ½ÄÚ²¿Âß¼ÀïÃ棬½çÃæ½ö½öÊÇÏÔʾºÍ½ÓÊÕÊäÈ룬¼´Ê¹Òª»»Ò»Ì×GUI£¬¹¤×÷Á¿Ò²²»´ó¡£ÕâͬʱҲÊÇÌá¸ß¿É²âÊÔÐÔµÄÊÖ¶ÎÖ®Ò»£¬µ±È»»¹ÓÐÆäËüһЩ¸½¼ÓºÃ´¦¡£ËùÒÔ¼´Ê¹Äã²ÉÓÃQT» ......
1.·Ö²ãÉè¼Æ£¬¸ôÀëƽ̨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇGUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çƽ̨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼þÖУ¬ÄÇôÕâ¸öÈí¼þµÄ¿ÉÖ²ÐÔ½«·Ç³£µÄ²î£¬ÕâÊDz»ÑÔ×ÔÃ÷µÄ¡£ÄÇôÈçºÎ±ÜÃâÕâÖÖÇé¿öÄØ£¿µ±È»ÊÇ·Ö²ãÉè¼ÆÁË£º
¡¡¡¡×îµ×²ã²ÉÓÃAdapterģʽ£¬°Ñ²»Í¬²Ù×÷ϵͳµÄAPI·â×°³ÉÒ»Ì×ͳһµÄ½Ó¿Ú¡£ÖÁÓÚ·â×°³ÉÀ໹ÊÇ·â×°³Éº¯Êý£¬Òª¿´Äã²ÉÓõÄC»¹ÊÇC++дµÄ³ÌÐòÁË¡£Õâ¿´ÆðÀ´ºÜ¼òµ¥£¬Æäʵ²»¾¡È»£¨¿´ÍêÕûƪÎÄÕºóÄã»áÃ÷°×µÄ£©£¬Ëü½«ºÄÈ¥Äã´óÁ¿µÄʱ¼äÈ¥±àд´úÂ룬ȥ²âÊÔËüÃÇ¡£²ÉÓÃÏÖ´æµÄ³ÌÐò¿â£¬ÊÇÃ÷ÖǵÄ×ö·¨£¬ÓкܶàÕâÑùµÄ¿â£¬±ÈÈ磬C¿âÓÐglib£¨GNOMEµÄ»ù´¡Àࣩ£¬C++¿âÓÐACE(ADAPTIVE Communication Environment)µÈµÈ£¬ÔÚ¿ª·¢µÚÒ»¸öƽ̨ʱ¾Í²ÉÓÃÕâЩ¿â£¬¿ÉÒÔ´ó´ó¼õÉÙÒÆÖ²µÄ¹¤×÷Á¿¡£
¡¡¡¡×îÉϲã²ÉÓÃMVCÄ£ÐÍ£¬·ÖÀë½çÃæ±íÏÖÓëÄÚ²¿Âß¼´úÂë¡£°Ñ´ó²¿·Ö´úÂë·Åµ½ÄÚ²¿Âß¼ÀïÃ棬½çÃæ½ö½öÊÇÏÔʾºÍ½ÓÊÕÊäÈ룬¼´Ê¹Òª»»Ò»Ì×GUI£¬¹¤×÷Á¿Ò²²»´ó¡£ÕâͬʱҲÊÇÌá¸ß¿É²âÊÔÐÔµÄÊÖ¶ÎÖ®Ò»£¬µ±È»»¹ÓÐÆäËüһЩ¸½¼ÓºÃ´¦¡£ËùÒÔ¼´Ê¹Äã²ÉÓÃQT» ......