锘??xml version="1.0" encoding="utf-8" standalone="yes"?>精品国产91久久久久久久a,91久久福利国产成人精品,色天使久久综合网天天http://www.shnenglu.com/biao/category/9972.html 鎴戜笉鑱槑錛屼絾鎴戜細寰堝姫鍔?/description>zh-cnSat, 03 Aug 2013 11:21:27 GMTSat, 03 Aug 2013 11:21:27 GMT60Qt錛欶ontMetricshttp://www.shnenglu.com/biao/archive/2013/08/03/202322.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Sat, 03 Aug 2013 10:27:00 GMThttp://www.shnenglu.com/biao/archive/2013/08/03/202322.htmlhttp://www.shnenglu.com/biao/comments/202322.htmlhttp://www.shnenglu.com/biao/archive/2013/08/03/202322.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/202322.htmlhttp://www.shnenglu.com/biao/services/trackbacks/202322.html鍦ㄤ竴涓猂ect鐨勬涓棿緇樺埗鏂囨湰: rect鐨勪腑鐐逛笌鏂囨湰鐨勪腑鐐歸噸鍚?
int cx = rect.x + rect.width / 2;
int fx = cx - fm.width(text);

int cy = rect.y + rect.height / 2;
int fy = cy + fm.xHeight / 2;



@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

]]>
C錛氬嚱鏁版寚閽堟暟緇勭殑瀹氫箟http://www.shnenglu.com/biao/archive/2013/07/26/202124.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Thu, 25 Jul 2013 23:56:00 GMThttp://www.shnenglu.com/biao/archive/2013/07/26/202124.htmlhttp://www.shnenglu.com/biao/comments/202124.htmlhttp://www.shnenglu.com/biao/archive/2013/07/26/202124.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/202124.htmlhttp://www.shnenglu.com/biao/services/trackbacks/202124.html
// [[1]] 浣跨敤typedef瀹氫箟鍑芥暟鎸囬拡涓轟竴涓被鍨嬶紝鏇村枩嬈㈣繖縐嶆柟寮?/font>
typedef int (*MYFUN)(int, int);
MYFUN funcs[10];

// [[2]] 浣跨敤typedef瀹氫箟鍑芥暟鎸囬拡鏁扮粍涓轟竴涓被鍨嬶紝涓嶆槸寰堢洿瑙?/font>
typedef int (*MYFUN2[10])(int, int);
MYFUN2 funcs2;

int main(int argc, char *argv[]) {
    funcs[0] = add;
    qDebug() << (*funcs[0])(2, 3); // 涔熷彲浠ョ敤 funcs[0](2, 3).

    funcs2[0] = add;
    qDebug() << (*funcs2[0])(2, 3);

    return 0;
}
@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

]]>
Qt錛氳В璇籕_GLOBAL_STATIC(QFontDatabasePrivate, privateDb) http://www.shnenglu.com/biao/archive/2013/06/26/201312.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Wed, 26 Jun 2013 02:02:00 GMThttp://www.shnenglu.com/biao/archive/2013/06/26/201312.htmlhttp://www.shnenglu.com/biao/comments/201312.htmlhttp://www.shnenglu.com/biao/archive/2013/06/26/201312.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/201312.htmlhttp://www.shnenglu.com/biao/services/trackbacks/201312.htmlFrom: http://zhgw01.blog.163.com/blog/static/1041481220105253491586/
鏍規嵁 src/corelib/global.h
 template <typename T>
class QGlobalStatic
{
public:
    T *pointer;
    inline QGlobalStatic(T *p) : pointer(p) { }
    inline ~QGlobalStatic() { pointer = 0; }
};

#define Q_GLOBAL_STATIC(TYPE, NAME)                              \
    static TYPE *NAME()                                          \
    {                                                            \
        static TYPE this_##NAME;                                 \
        static QGlobalStatic<TYPE > global_##NAME(&this_##NAME); \
        return global_##NAME.pointer;                            \
    }

   

涓婇潰鐨勫睍寮鎴?/span>
 static  QFontDatabasePrivate *privateDb()
{
    static QFontDatabasePrivate this_privateDb;  // 娉ㄦ剰絎竴嬈″紩鐢ㄧ殑鏃跺欎細寮濮嬭繘琛屽垵濮嬪寲, 浠ュ悗涓嶅啀鐢熸垚
   static QGLobalStatic<QFontDatabasePrivate> global_privateDb(&this_privateDb); //瀵逛笂闈㈢敓鎴愮殑瀵硅薄鐨勬寚閽堣繘琛屽寘瑁咃紝 鍚屼笂錛屽彧鏈夌涓嬈℃墠浼氱敓鎴?br />
  return global_privateDb;
}

QFontDatabase鐨勬瀯閫犲嚱鏁頒腑浼氳皟鐢╟reateDatabase 錛堥噷闈㈣皟鐢ㄤ簡initializeDb), initializeDb閲岃皟鐢ㄤ簡privateDb(),涓涓繖涓椂鍊欐槸絎竴嬈¤皟鐢紝 浼氱敓鎴怮FontDatabasePrivate瀵硅薄

QFontDatabasePrivate涓殑QDataStream *stream鎴愬憳鎵嶆槸鐪熸澶勭悊qte鐨勫瓧浣?/p>

]]>
C++錛歈T鎻掍歡寮鍙戞柟寮?/title><link>http://www.shnenglu.com/biao/archive/2013/06/25/201308.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Tue, 25 Jun 2013 15:26:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2013/06/25/201308.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/201308.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2013/06/25/201308.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/201308.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/201308.html</trackback:ping><description><![CDATA[From: http://blog.csdn.net/henreash/article/details/7264489@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); <div> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">鍒涘緩涓涓猀T鐨勫簱欏圭洰,鍒犻櫎鑷姩鐢熸垚鐨?h鍜?cpp鏂囦歡,娣誨姞涓涓帴鍙e畾涔?h鏂囦歡鍜屼竴涓帴鍙e疄鐜扮被(涓涓?h涓涓?cpp).浠g爜濡備笅:</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">1.鎺ュ彛鏂囦歡婧愮爜</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#ifndef PLUGININTERFACE_H<br /> #define PLUGININTERFACE_H</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#include <QString></p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; "><br /> class EchoInterface<br /> {<br /> public:<br />  virtual ~EchoInterface() {}<br />  virtual QString echo(const QString &message) = 0;<br /> };</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">QT_BEGIN_NAMESPACE<br /> Q_DECLARE_INTERFACE(EchoInterface, "com.hollysys.plugin.EchoIntrface/1.0");<br /> QT_END_NAMESPACE</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; "><br /> #endif</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">2.鎺ュ彛瀹炵幇綾誨ご鏂囦歡</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#ifndef PLUGIN_H<br /> #define PLUGIN_H</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">//#include "plugin_global.h"<br /> #include <QObject><br /> #include "plugininterface.h"</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">class Plugin : public QObject, EchoInterface<br /> {<br />  Q_OBJECT<br />  Q_INTERFACES(EchoInterface)<br /> public:<br />  Plugin();<br />  ~Plugin();<br /> public:<br />  QString echo(const QString &message);</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; "><br /> };</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#endif // PLUGIN_H</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">3.鎺ュ彛瀹炵幇綾籧pp鏂囦歡</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#include "plugin.h"<br /> #include <QtGui></p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; "><br /> Plugin::Plugin()<br /> {</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">}</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">Plugin::~Plugin()<br /> {</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">}</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">QString Plugin::echo(const QString &message)<br /> {<br />  return message;<br /> }</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">Q_EXPORT_PLUGIN2("echoPlugin", Plugin);<br /> </p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">緙栬瘧鐢熸垚dll鏍煎紡鐨勬彃浠?榪欓噷鍙兘浼氶亣鍒癓NK2001閿欒,鍥犱負鎻掍歡鎺ュ彛瀹氫箟渚濊禆浜嶲T鐨勫厓鏁版嵁,鑰屽湪浠g爜涓墜鍔ㄦ坊鍔燪_OBJECT瀹忓悗,緙栬瘧鍣ㄤ笉浼氳嚜鍔ㄤ負鎴戜滑鐢熸垚moc_XXXX.cpp鏂囦歡,鍥犳闇瑕佷嬌鐢ㄥ懡浠よ鐢熸垚moc鍏冩暟鎹枃浠?cmd-->cd 婧愮爜鎵鍦ㄥ懡浠?-->moc -o moc_XXXX.cpp XXXX.h.榪欐牱灝卞彲浠ユ墜鍔ㄥ垱寤哄嚭moc鍏冩暟鎹枃浠?瑙e喅LNK2001緙栬瘧閿欒.</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">寤虹珛涓涓狦UI嫻嬭瘯欏圭洰,浠g爜濡備笅:</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">#include "test.h"<br /> #include <QtGui><br /> #include <QMessageBox><br /> #include <QDir></p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">Test::Test(QWidget *parent, Qt::WFlags flags)<br />  : QMainWindow(parent, flags)<br /> {<br />  ui.setupUi(this);<br />  QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(ButtonClicked()));<br />  loadPlugin();<br /> }</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">Test::~Test()<br /> {</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">}</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">bool Test::loadPlugin()<br /> {<br />  QDir pluginsDir(qApp->applicationDirPath());<br />  foreach (QString filename, pluginsDir.entryList(QDir::Files))<br />  {<br />   QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(filename));<br />   QObject *plugin = pluginLoader.instance();<br />   if(plugin)<br />   {<br />    echoInterface = qobject_cast<EchoInterface *>(plugin);//echoInterface鏄垚鍛樺彉閲?br />    if(echoInterface)<br />     return true;<br />   }<br />  }<br /> }</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">void Test::ButtonClicked()<br /> {<br />  QString plugin = ui.lineEdit->text();<br />  QMessageBox::information(NULL, "", echoInterface->echo(plugin));<br /> }</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">鍒嗘瀽浠g爜鍙,榪欓噷瀵規墍鏈変笌exe鏂囦歡鍚岀洰褰曠殑鏂囦歡灝濊瘯鍔犺澆鎻掍歡,濡傛灉鍔犺澆鎴愬姛鍒欒繑鍥?浠g爜瀹炵幇闈炲父綆媧?鍦ㄦ寮忓紑鍙戜腑鍙皢宸插姞杞界殑鎻掍歡鎺ュ彛瀛樻斁鍦ㄥ垪琛ㄤ腑,鍦ㄩ渶瑕佺殑鏃跺欎緷嬈¤皟鐢ㄥ嵆鍙?</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">鍙﹀濡傛灉鎯寵幏鍙栨彃浠朵腑綾誨畾涔夌殑鍏冩暟鎹?鍙互浣挎彃浠舵帴鍙g被浠嶲Object緇ф壙,騫朵嬌鐢≦_CLASSINFO瀹忔坊鍔犻敭鍊煎,濡俀_CLASSINFO("Author**", "Henreash**").騫朵粠涓葷▼搴忎腑浣跨敤鎻掍歡瀵硅薄鍏冩暟鎹幏鍙栬繖浜涢敭鍊煎:</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; "> const QMetaObject *mo = echoInterface->metaObject();<br />  for(int i = 0; i < mo->classInfoCount(); i++)<br />  {<br />   qDebug() << mo->classInfo(i).name() << mo->classInfo(i).value();<br />  }</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">浣跨敤榪欎釜鏈哄埗鍙互鍦ㄥ畾涔夋彃浠剁被鐨勬椂鍊欏悜涓葷▼搴忎紶閫掍竴浜涚壒孌婁俊鎭?</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; background-color: #ffffff; ">嫻嬭瘯鍙戠幇,濡傛灉鍦ㄦ彃浠舵帴鍙g被涓畾涔変竴涓潤鎬佸彉閲?閭d箞榪欎釜闈欐佸彉閲忓湪鎻掍歡涓殑鍦板潃鍜屽湪涓葷▼搴忎腑鐨勫湴鍧鏄笉鐩稿悓鐨?</p> </div><img src ="http://www.shnenglu.com/biao/aggbug/201308.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2013-06-25 23:26 <a href="http://www.shnenglu.com/biao/archive/2013/06/25/201308.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++錛氬崟渚?Singletonhttp://www.shnenglu.com/biao/archive/2013/06/25/201306.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Tue, 25 Jun 2013 13:46:00 GMThttp://www.shnenglu.com/biao/archive/2013/06/25/201306.htmlhttp://www.shnenglu.com/biao/comments/201306.htmlhttp://www.shnenglu.com/biao/archive/2013/06/25/201306.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/201306.htmlhttp://www.shnenglu.com/biao/services/trackbacks/201306.htmlFrom: http://zh.wikipedia.org/wiki/鍗曚緥妯″紡

鍦?a title="C++" style="text-decoration: none; color: #0b0080; background-image: none; background-position: initial initial; background-repeat: initial initial; ">C++緙栫▼璇█涓紝鍗曚緥妯″紡搴旂敤鐨勪緥瀛愬涓嬭堪浠g爜鎵紺猴紙榪欓噷浠呬粎鎻愪緵涓涓ず渚嬶紝榪欎釜渚嬪瓙瀵瑰綰跨▼鐨勬儏鍐靛茍涓嶆槸瀹夊叏鐨勶級錛?/p>

// ...
class lock
{
public:
lock();
lock(lock const & l);
~lock();
lock & operator =(lock const & l);
void request();
void release();
// ...
};
lock::lock()
{
// ...
}
// ...
lock::~lock()
{
// ...
}
// ...
void lock::request()
{
// ...
}
void lock::release()
{
// ...
}
// ...
// assumes _DATA_TYPE_ has a default constructor
template<typename _DATA_TYPE_>
class singleton
{
public:
static _DATA_TYPE_ * request();
static void release();
private:
singleton();
singleton(singleton<_DATA_TYPE_> const & s);
~singleton();
singleton<_DATA_TYPE_> & operator =(singleton<_DATA_TYPE_> const & s);
static _DATA_TYPE_ * pointer;
static lock mutex;
// ...
};
template<typename _DATA_TYPE_>
_DATA_TYPE_ * singleton<_DATA_TYPE_>::pointer = 0;
template<typename _DATA_TYPE_>
lock singleton<_DATA_TYPE_>::mutex;
template<typename _DATA_TYPE_>
_DATA_TYPE_ * singleton<_DATA_TYPE_>::request()
{
if(singleton<_DATA_TYPE_>::pointer == 0)
{
singleton<_DATA_TYPE_>::mutex.request();
if(singleton<_DATA_TYPE_>::pointer == 0)
{
singleton<_DATA_TYPE_>::pointer = new _DATA_TYPE_;
}
singleton<_DATA_TYPE_>::mutex.release();
}
return singleton<_DATA_TYPE_>::pointer;
}
template<typename _DATA_TYPE_>
void singleton<_DATA_TYPE_>::release()
{
if(singleton<_DATA_TYPE_>::pointer != 0)
{
singleton<_DATA_TYPE_>::mutex.request();
if(singleton<_DATA_TYPE_>::pointer != 0)
{
delete singleton<_DATA_TYPE_>::pointer;
singleton<_DATA_TYPE_>::pointer = 0;
}
singleton<_DATA_TYPE_>::mutex.release();
}
}
template<typename _DATA_TYPE_>
singleton<_DATA_TYPE_>::singleton()
{
// ...
}
// ...
int main()
{
int * s;
s = singleton<int>::request();
// ...
singleton<int>::release();
return 0;
}

@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

]]>
OpenGL錛氬睍紺篛penGL鐗規х殑杞歡Tutorshttp://www.shnenglu.com/biao/archive/2013/04/19/199557.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Thu, 18 Apr 2013 16:24:00 GMThttp://www.shnenglu.com/biao/archive/2013/04/19/199557.htmlhttp://www.shnenglu.com/biao/comments/199557.htmlhttp://www.shnenglu.com/biao/archive/2013/04/19/199557.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/199557.htmlhttp://www.shnenglu.com/biao/services/trackbacks/199557.html nate robins
main OPENGL chronicles allies
--- Tutors ---

Tutors source code package (tutors-src.zip 920KB) 

Source package + Windows executables (tutors-win32.zip 1.24MB) 

Source package + Mac OS X universal binaries (tutors-macosx.zip 1.2MB) 

Contributions from various people (Unix makefiles, etc). 

fog
(click on image to enlarge it)
The fog tutorial program (shown at right) demonstrates how to use depth cueing (or fog) in OpenGL. It includes command panels that allow dynamic update of the parameters for linear, exponential and exponential2 fog functions. The fog color can also be dynamically changed.
lightposition
(click on image to enlarge it)
The lightposition tutorial program (shown at left) demonstrates how lighting position is effected by the viewing transformation. The order in which the light position and the viewing transform are established is configurable, as are the parameters for the position and transform.
lightmaterial
(click on image to enlarge it)

The lightmaterial tutorial program (shown above) demonstrates how OpenGL lighting and material properties interact and effect each other. All material & light properties are tweakable. A second command panel allows spotlight parameters & attenuation factors to be changed.
projection
(click on image to enlarge it)
The projection tutorial program (shown at right) demonstrates how the many types of projection transformations work. A command panel is included for gluPerspective(), glOrtho() and glFrustum(). In addition, the viewing transform can be modified via the gluLookat() function.
transformation
(click on image to enlarge it)
The transformation tutorial program (shown at left) demonstrates how the basic transformations of rotate, translate and scale operate in OpenGL. The order of the transforms can be changed to see how that effects rendering.
texture
(click on image to enlarge it)

The texture tutorial program (shown above) demonstrates how OpenGL texturing works. Specifically, the texture coordinates for a polygon are provided for manipulation as are the polygons coordinates themselves. The texture parameter & environment attributes are tweakable. A separate command panel allows manipulation of the texture matrix.
shapes
(click on image to enlarge it)
The shapes tutorial program (shown at right) demonstrates how the many types of primitives work. A command panel for each primitive type is included. This tutorial was written by Mason Woo (mason@woo.com).



--- --- ---

@import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

]]>
C++錛歀IB鍜孌LL鐨勫尯鍒笌浣跨敤http://www.shnenglu.com/biao/archive/2013/03/14/198416.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Thu, 14 Mar 2013 06:38:00 GMThttp://www.shnenglu.com/biao/archive/2013/03/14/198416.htmlhttp://www.shnenglu.com/biao/comments/198416.htmlhttp://www.shnenglu.com/biao/archive/2013/03/14/198416.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/198416.htmlhttp://www.shnenglu.com/biao/services/trackbacks/198416.html鍏辨湁涓ょ搴擄細
涓縐嶆槸LIB鍖呭惈浜嗗嚱鏁版墍鍦ㄧ殑DLL鏂囦歡鍜屾枃浠朵腑鍑芥暟浣嶇疆鐨勪俊鎭紙鍏ュ彛錛夛紝浠g爜鐢辮繍琛屾椂鍔犺澆鍦ㄨ繘紼嬬┖闂翠腑鐨凞LL鎻愪緵錛岀О涓哄姩鎬侀摼鎺ュ簱dynamic link library銆?/span>
涓縐嶆槸LIB鍖呭惈鍑芥暟浠g爜鏈韓錛屽湪緙栬瘧鏃剁洿鎺ュ皢浠g爜鍔犲叆紼嬪簭褰撲腑錛岀О涓洪潤鎬侀摼鎺ュ簱static link library銆?/span>
鍏辨湁涓ょ閾炬帴鏂瑰紡錛?/span>
鍔ㄦ侀摼鎺ヤ嬌鐢ㄥ姩鎬侀摼鎺ュ簱錛屽厑璁稿彲鎵ц妯″潡錛?dll鏂囦歡鎴?exe鏂囦歡錛変粎鍖呭惈鍦ㄨ繍琛屾椂瀹氫綅DLL鍑芥暟鐨勫彲鎵ц浠g爜鎵闇鐨勪俊鎭?/span>
闈欐侀摼鎺ヤ嬌鐢ㄩ潤鎬侀摼鎺ュ簱錛岄摼鎺ュ櫒浠庨潤鎬侀摼鎺ュ簱LIB鑾峰彇鎵鏈夎寮曠敤鍑芥暟錛屽茍灝嗗簱鍚屼唬鐮佷竴璧鋒斁鍒板彲鎵ц鏂囦歡涓?/span>

鍏充簬lib鍜宒ll鐨勫尯鍒涓嬶細
錛?錛塴ib鏄紪璇戞椂鐢ㄥ埌鐨勶紝dll鏄繍琛屾椂鐢ㄥ埌鐨勩傚鏋滆瀹屾垚婧愪唬鐮佺殑緙栬瘧錛屽彧闇瑕乴ib錛涘鏋滆浣垮姩鎬侀摼鎺ョ殑紼嬪簭榪愯璧鋒潵錛屽彧闇瑕乨ll銆?/span>
錛?錛夊鏋滄湁dll鏂囦歡錛岄偅涔坙ib涓鑸槸涓浜涚儲寮曚俊鎭紝璁板綍浜哾ll涓嚱鏁扮殑鍏ュ彛鍜屼綅緗紝dll涓槸鍑芥暟鐨勫叿浣撳唴瀹癸紱濡傛灉鍙湁lib鏂囦歡錛岄偅涔堣繖涓猯ib鏂囦歡鏄潤鎬佺紪璇戝嚭鏉ョ殑錛岀儲寮曞拰瀹炵幇閮藉湪鍏朵腑銆備嬌鐢ㄩ潤鎬佺紪璇戠殑lib鏂囦歡錛屽湪榪愯紼嬪簭鏃朵笉闇瑕佸啀鎸傚姩鎬佸簱錛岀己鐐規槸瀵艱嚧搴旂敤紼嬪簭姣旇緝澶э紝鑰屼笖澶卞幓浜嗗姩鎬佸簱鐨勭伒媧繪э紝鍙戝竷鏂扮増鏈椂瑕佸彂甯冩柊鐨勫簲鐢ㄧ▼搴忔墠琛屻?/span>
錛?錛夊姩鎬侀摼鎺ョ殑鎯呭喌涓嬶紝鏈変袱涓枃浠訛細涓涓槸LIB鏂囦歡錛屼竴涓槸DLL鏂囦歡銆侺IB鍖呭惈琚獶LL瀵煎嚭鐨勫嚱鏁板悕縐板拰浣嶇疆錛孌LL鍖呭惈瀹為檯鐨勫嚱鏁板拰鏁版嵁錛屽簲鐢ㄧ▼搴忎嬌鐢↙IB鏂囦歡閾炬帴鍒癉LL鏂囦歡銆傚湪搴旂敤紼嬪簭鐨勫彲鎵ц鏂囦歡涓紝瀛樻斁鐨勪笉鏄璋冪敤鐨勫嚱鏁頒唬鐮侊紝鑰屾槸DLL涓浉搴斿嚱鏁頒唬鐮佺殑鍦板潃錛屼粠鑰岃妭鐪佷簡鍐呭瓨璧勬簮銆侱LL鍜孡IB鏂囦歡蹇呴』闅忓簲鐢ㄧ▼搴忎竴璧峰彂琛岋紝鍚﹀垯搴旂敤紼嬪簭浼氫駭鐢熼敊璇傚鏋滀笉鎯崇敤lib鏂囦歡鎴栬呮病鏈塴ib鏂囦歡錛屽彲浠ョ敤WIN32 API鍑芥暟LoadLibrary銆丟etProcAddress瑁呰澆銆?/span>

浣跨敤lib闇娉ㄦ剰涓や釜鏂囦歡錛?/span>
錛?錛?h澶存枃浠訛紝鍖呭惈lib涓鏄庤緭鍑虹殑綾繪垨絎﹀彿鍘熷瀷鎴栨暟鎹粨鏋勩傚簲鐢ㄧ▼搴忚皟鐢╨ib鏃訛紝闇瑕佸皢璇ユ枃浠跺寘鍚叆搴旂敤紼嬪簭鐨勬簮鏂囦歡涓?/span>
錛?錛?LIB鏂囦歡錛岀暐銆?/span>

浣跨敤dll闇娉ㄦ剰涓変釜鏂囦歡錛?/span>
錛?錛?h澶存枃浠訛紝鍖呭惈dll涓鏄庤緭鍑虹殑綾繪垨絎﹀彿鍘熷瀷鎴栨暟鎹粨鏋勭殑.h鏂囦歡銆傚簲鐢ㄧ▼搴忚皟鐢╠ll鏃訛紝闇瑕佸皢璇ユ枃浠跺寘鍚叆搴旂敤紼嬪簭鐨勬簮鏂囦歡涓?/span>
錛?錛?LIB鏂囦歡錛屾槸dll鍦ㄧ紪璇戙侀摼鎺ユ垚鍔熶箣鍚庣敓鎴愮殑鏂囦歡錛屼綔鐢ㄦ槸褰撳叾浠栧簲鐢ㄧ▼搴忚皟鐢╠ll鏃訛紝闇瑕佸皢璇ユ枃浠跺紩鍏ュ簲鐢ㄧ▼搴忥紝鍚﹀垯浜х敓閿欒銆?/span>濡傛灉涓嶆兂鐢╨ib鏂囦歡鎴栬呮病鏈塴ib鏂囦歡錛屽彲浠ョ敤WIN32 API鍑芥暟LoadLibrary銆丟etProcAddress瑁呰澆銆?br />錛?錛?dll鏂囦歡錛岀湡姝g殑鍙墽琛屾枃浠訛紝寮鍙戞垚鍔熷悗鐨勫簲鐢ㄧ▼搴忓湪鍙戝竷鏃訛紝鍙渶瑕佹湁.exe鏂囦歡鍜?dll鏂囦歡錛屽茍涓嶉渶瑕?lib鏂囦歡鍜?h澶存枃浠躲?/span>

浣跨敤lib鐨勬柟娉曪細
闈欐乴ib涓紝涓涓猯ib鏂囦歡瀹為檯涓婃槸浠繪剰涓猳bj鏂囦歡鐨勯泦鍚堬紝obj鏂囦歡鏄痗pp鏂囦歡緙栬瘧鐢熸垚鐨勩傚湪緙栬瘧榪欑闈欐佸簱宸ョ▼鏃訛紝鏍規湰涓嶄細閬囧埌閾炬帴閿欒錛涘嵆浣挎湁閿欙紝涔熷彧浼氬湪浣跨敤榪欎釜lib鐨凟XT鏂囦歡鎴栬匘LL宸ョ▼閲屾毚闇插嚭鏉ャ?/span>
鍦╒C涓柊寤轟竴涓猻tatic library綾誨瀷鐨勫伐紼婰ib錛屽姞鍏est.cpp鏂囦歡鍜宼est.h鏂囦歡錛堝ご鏂囦歡鍐呭寘鎷嚱鏁板0鏄庯級錛岀劧鍚庣紪璇戯紝灝辯敓鎴愪簡Lib.lib鏂囦歡銆?/span>
鍒殑宸ョ▼瑕佷嬌鐢ㄨ繖涓猯ib鏈変袱縐嶆柟寮忥細
錛?錛夊湪project->link->Object/Library Module涓姞鍏ib.lib鏂囦歡錛堝厛鏌ヨ宸ョ▼鐩綍錛屽啀鏌ヨ緋葷粺Lib鐩綍錛夛紱鎴栬呭湪婧愪唬鐮佷腑鍔犲叆鎸囦護#pragma comment(lib, “Lib.lib”)銆?/span>
錛?錛夊皢Lib.lib鎷峰叆宸ョ▼鎵鍦ㄧ洰褰曪紝鎴栬呮墽琛屾枃浠剁敓鎴愮殑鐩綍錛屾垨鑰呯郴緇烲ib鐩綍涓?/span>
錛?錛夊姞鍏ョ浉搴旂殑澶存枃浠秚est.h銆?/span>

浣跨敤DLL鐨勬柟娉曪細
浣跨敤鍔ㄦ侀摼鎺ヤ腑鐨刲ib錛屼笉鏄痮bj鏂囦歡鐨勯泦鍚堬紝鍗抽噷闈笉浼氭湁瀹為檯鐨勫疄鐜幫紝瀹冨彧鏄彁渚涘姩鎬侀摼鎺ュ埌DLL鎵闇瑕佺殑淇℃伅錛岃繖縐峫ib鍙互鍦ㄧ紪璇戜竴涓狣LL宸ョ▼鏃剁敱緙栬瘧鍣ㄧ敓鎴愩?/span>
鍒涘緩DLL宸ョ▼鐨勬柟娉曪紙鐣ワ級銆?/span>
錛?錛夐殣寮忛摼鎺?/strong>
絎竴縐嶆柟娉曟槸錛氶氳繃project->link->Object/Library Module涓姞鍏?lib鏂囦歡錛堟垨鑰呭湪婧愪唬鐮佷腑鍔犲叆鎸囦護#pragma comment(lib, “Lib.lib”)錛夛紝騫跺皢.dll鏂囦歡緗叆宸ョ▼鎵鍦ㄧ洰褰曪紝鐒跺悗娣誨姞瀵瑰簲鐨?h澶存枃浠躲?/span>

#include "stdafx.h"
#include "DLLSample.h"

#pragma comment(lib, "DLLSample.lib")    //浣犱篃鍙互鍦ㄩ」鐩睘鎬т腑璁劇疆搴撶殑閾炬帴

int main()
{
        TestDLL(123);   //dll涓殑鍑芥暟錛屽湪DllSample.h涓0鏄?/span>
        return(1);
}

錛?錛夋樉寮忛摼鎺?/strong>
闇瑕佸嚱鏁版寚閽堝拰WIN32 API鍑芥暟LoadLibrary銆丟etProcAddress瑁呰澆錛屼嬌鐢ㄨ繖縐嶈澆鍏ユ柟娉曪紝涓嶉渶瑕?lib鏂囦歡鍜?h澶存枃浠訛紝鍙渶瑕?dll鏂囦歡鍗沖彲錛堝皢.dll鏂囦歡緗叆宸ョ▼鐩綍涓級銆?/span>

#include <iostream>
#include <windows.h>         //浣跨敤鍑芥暟鍜屾煇浜涚壒孌婂彉閲?/span>
typedef void (*DLLFunc)(int);
int main()
{
        DLLFunc dllFunc;
        HINSTANCE hInstLibrary = LoadLibrary("DLLSample.dll");

        
if (hInstLibrary == NULL)
        
{
          FreeLibrary(hInstLibrary);
        }

        dllFunc = (DLLFunc)GetProcAddress(hInstLibrary, "TestDLL");
        
if (dllFunc == NULL)
        
{
          FreeLibrary(hInstLibrary);
        }

        dllFunc(123);
        std::cin.get();
        FreeLibrary(hInstLibrary);
        
return(1);
}


LoadLibrary鍑芥暟鍒╃敤涓涓悕縐頒綔涓哄弬鏁幫紝鑾峰緱DLL鐨勫疄渚嬶紙HINSTANCE綾誨瀷鏄疄渚嬬殑鍙ユ焺錛夛紝閫氬父璋冪敤璇ュ嚱鏁板悗闇瑕佹煡鐪嬩竴涓嬪嚱鏁拌繑鍥炴槸鍚︽垚鍔燂紝濡傛灉涓嶆垚鍔熷垯榪斿洖NULL錛堝彞鏌勬棤鏁堬級錛屾鏃惰皟鐢ㄥ嚱鏁癋reeLibrary閲婃斁DLL鑾峰緱鐨勫唴瀛樸?/span>
GetProcAddress鍑芥暟鍒╃敤DLL鐨勫彞鏌勫拰鍑芥暟鐨勫悕縐頒綔涓哄弬鏁幫紝榪斿洖鐩稿簲鐨勫嚱鏁版寚閽堬紝鍚屾椂蹇呴』浣跨敤寮鴻漿錛涘垽鏂嚱鏁版寚閽堟槸鍚︿負NULL錛屽鏋滄槸鍒欒皟鐢ㄥ嚱鏁癋reeLibrary閲婃斁DLL鑾峰緱鐨勫唴瀛樸傛鍚庯紝鍙互浣跨敤鍑芥暟鎸囬拡鏉ヨ皟鐢ㄥ疄闄呯殑鍑芥暟銆?/span>
鏈鍚庤璁板緱浣跨敤FreeLibrary鍑芥暟閲婃斁鍐呭瓨銆?/span>

娉ㄦ剰錛氬簲鐢ㄧ▼搴忓浣曟壘鍒癉LL鏂囦歡錛?/span>
浣跨敤LoadLibrary鏄懼紡閾炬帴錛岄偅涔堝湪鍑芥暟鐨勫弬鏁頒腑鍙互鎸囧畾DLL鏂囦歡鐨勫畬鏁磋礬寰勶紱濡傛灉涓嶆寚瀹氳礬寰勶紝鎴栬呰繘琛岄殣寮忛摼鎺ワ紝Windows灝嗛伒寰笅闈㈢殑鎼滅儲欏哄簭鏉ュ畾浣岲LL錛?/span>
錛?錛夊寘鍚獷XE鏂囦歡鐨勭洰褰?/span>
錛?錛夊伐紼嬬洰褰?/span>
錛?錛塛indows緋葷粺鐩綍
錛?錛塛indows鐩綍
錛?錛夊垪鍦≒ath鐜鍙橀噺涓殑涓緋誨垪鐩綍

From: http://www.shnenglu.com/ming81/archive/2013/03/04/198215.html

.h澶存枃浠舵槸緙栬瘧鏃跺繀欏葷殑錛宭ib鏄摼鎺ユ椂闇瑕佺殑錛宒ll鏄繍琛屾椂闇瑕佺殑銆?/span>

闄勫姞渚濊禆欏圭殑鏄?lib涓嶆槸.dll錛岃嫢鐢熸垚浜咲LL,鍒欒偗瀹氫篃鐢熸垚 LIB鏂囦歡銆傚鏋滆瀹屾垚婧愪唬鐮佺殑緙栬瘧鍜岄摼鎺ワ紝鏈夊ご鏂囦歡鍜宭ib灝卞浜嗐傚鏋滀篃浣垮姩鎬佽繛鎺ョ殑紼嬪簭榪愯璧鋒潵錛屾湁dll灝卞浜嗐傚湪寮鍙戝拰璋冭瘯闃舵錛屽綋鐒舵渶濂介兘鏈夈?/span>

.h .lib .dll涓夎呯殑鍏崇郴鏄細

H鏂囦歡浣滅敤鏄?澹版槑鍑芥暟鎺ュ彛 

DLL鏂囦歡浣滅敤鏄? 鍑芥暟鍙墽琛屼唬鐮?nbsp;

褰撴垜浠湪鑷繁鐨勭▼搴忎腑寮曠敤浜嗕竴涓狧鏂囦歡閲岀殑鍑芥暟,緙栭摼鍣ㄦ庝箞鐭ラ亾璇ヨ皟鐢ㄥ摢涓狣LL鏂囦歡鍛?榪欏氨鏄疞IB鏂囦歡鐨勪綔鐢? 鍛婅瘔閾炬帴鍣?璋冪敤鐨勫嚱鏁板湪鍝釜DLL涓紝鍑芥暟鎵ц浠g爜鍦―LL涓殑浠涔堜綅緗?錛岃繖涔熷氨鏄負浠涔堥渶瑕侀檮鍔犱緷璧栭」 .LIB鏂囦歡錛屽畠璧峰埌妗ユ鐨勪綔鐢ㄣ傚鏋滅敓鎴愰潤鎬佸簱鏂囦歡錛屽垯娌℃湁DLL 錛屽彧鏈塴ib錛岃繖鏃跺嚱鏁板彲鎵ц浠g爜閮ㄥ垎涔熷湪lib鏂囦歡涓?/span>

鐩墠浠ib鍚庣紑鐨勫簱鏈変袱縐嶏紝涓縐嶄負闈欐侀摼鎺ュ簱(Static Libary錛屼互涓嬬畝縐?#8220;闈欐佸簱”)錛屽彟涓縐嶄負鍔ㄦ佽繛鎺ュ簱(DLL錛屼互涓嬬畝縐?#8220;鍔ㄦ佸簱”)鐨勫鍏ュ簱(Import Libary錛屼互涓嬬畝縐?#8220;瀵煎叆搴?#8221;錛夈傞潤鎬佸簱鏄竴涓垨鑰呭涓猳bj鏂囦歡鐨勬墦鍖?錛屾墍浠ユ湁浜哄共鑴嗘妸浠巓bj鏂囦歡鐢熸垚lib鐨勮繃紼嬬О涓篈rchive錛屽嵆鍚堝茍鍒頒竴璧楓傛瘮濡備綘閾炬帴涓涓潤鎬佸簱錛屽鏋滃叾涓湁閿欙紝瀹冧細鍑嗙‘鐨勬壘鍒版槸鍝釜obj鏈夐敊錛屽嵆闈欐乴ib鍙槸澹沖瓙銆傚姩鎬佸簱涓鑸細鏈夊搴旂殑瀵煎叆搴擄紝鏂逛究紼嬪簭闈欐佽澆鍏ュ姩鎬侀摼鎺ュ簱 錛屽惁鍒欎綘鍙兘灝遍渶瑕佽嚜宸盠oadLibary璋冨叆DLL鏂囦歡錛岀劧鍚庡啀鎵嬪伐GetProcAddress鑾峰緱瀵瑰簲鍑芥暟浜嗐傛湁浜嗗鍏ュ簱錛屼綘鍙渶瑕侀摼鎺ュ鍏ュ簱鍚庢寜鐓уご鏂囦歡鍑芥暟鎺ュ彛鐨勫0鏄庤皟鐢ㄥ嚱鏁板氨鍙互浜嗐傚鍏ュ簱鍜岄潤鎬佸簱鐨勫尯鍒緢澶э紝浠栦滑瀹炶川鏄笉涓鏍風殑涓滆タ銆傞潤鎬佸簱鏈韓灝卞寘鍚簡瀹為檯鎵ц浠g爜銆佺鍙瘋〃絳夌瓑錛岃屽浜庡鍏ュ簱鑰岃█錛屽叾瀹為檯鐨勬墽琛屼唬鐮佷綅浜庡姩鎬佸簱涓紝瀵煎叆搴撳彧鍖呭惈浜嗗湴鍧絎﹀彿琛ㄧ瓑錛岀‘淇濈▼搴忔壘鍒板搴斿嚱鏁扮殑涓浜涘熀鏈湴鍧淇℃伅銆?/span>

涓鑸殑鍔ㄦ佸簱紼嬪簭鏈塴ib鏂囦歡鍜宒ll鏂囦歡銆俵ib鏂囦歡鏄繀欏誨湪緙栬瘧鏈熷氨榪炴帴鍒板簲鐢ㄧ▼搴忎腑鐨勶紝鑰宒ll鏂囦歡鏄繍琛屾湡鎵嶄細琚皟鐢ㄧ殑銆?濡傛灉鏈塪ll鏂囦歡錛岄偅涔堝搴旂殑lib鏂囦歡涓鑸槸涓浜涚儲寮曚俊鎭紝鍏蜂綋鐨勫疄鐜板湪dll鏂囦歡涓傚鏋滃彧鏈塴ib鏂囦歡錛岄偅涔堣繖涓猯ib鏂囦歡鏄潤鎬佺紪璇戝嚭鏉ョ殑錛岀儲寮曞拰瀹炵幇閮藉湪鍏朵腑銆傞潤鎬佺紪璇戠殑lib鏂囦歡鏈夊ソ澶勶細緇欑敤鎴峰畨瑁呮椂灝變笉闇瑕佸啀鎸傚姩鎬佸簱浜嗐備絾涔熸湁緙虹偣錛屽氨鏄鑷村簲鐢ㄧ▼搴忔瘮杈冨ぇ錛岃屼笖澶卞幓浜嗗姩鎬佸簱鐨勭伒媧繪э紝鍦ㄧ増鏈崌綰ф椂錛屽悓鏃惰鍙戝竷鏂扮殑搴旂敤紼嬪簭鎵嶈銆傚湪鍔ㄦ佸簱鐨勬儏鍐典笅錛屾湁涓や釜鏂囦歡錛岃屼竴涓槸寮曞叆搴擄紙.LIB錛夋枃浠訛紝涓涓槸DLL鏂囦歡錛屽紩鍏ュ簱鏂囦歡鍖呭惈琚獶LL瀵煎嚭鐨勫嚱鏁扮殑鍚嶇О鍜屼綅緗紝DLL鍖呭惈瀹為檯鐨勫嚱鏁板拰鏁版嵁錛屽簲鐢ㄧ▼搴忎嬌鐢↙IB鏂囦歡閾炬帴鍒版墍闇瑕佷嬌鐢ㄧ殑DLL鏂囦歡錛屽簱涓殑鍑芥暟鍜屾暟鎹茍涓嶅鍒跺埌鍙墽琛屾枃浠朵腑錛屽洜姝ゅ湪搴旂敤紼嬪簭鐨勫彲鎵ц鏂囦歡涓紝瀛樻斁鐨勪笉鏄璋冪敤鐨勫嚱鏁頒唬鐮侊紝鑰屾槸DLL涓墍瑕佽皟鐢ㄧ殑鍑芥暟鐨勫唴瀛樺湴鍧錛岃繖鏍峰綋涓涓垨澶氫釜搴旂敤紼嬪簭榪愯鏄啀鎶婄▼搴忎唬鐮佸拰琚皟鐢ㄧ殑鍑芥暟浠g爜閾炬帴璧鋒潵錛屼粠鑰岃妭鐪佷簡鍐呭瓨璧勬簮銆備粠涓婇潰鐨勮鏄庡彲浠ョ湅鍑猴紝DLL鍜?LIB鏂囦歡蹇呴』闅忓簲鐢ㄧ▼搴忎竴璧峰彂琛岋紝鍚﹀垯搴旂敤紼嬪簭灝嗕細浜х敓閿欒銆?/span>

闈欐佸簱鍜屽叡浜簱閮芥槸涓涓猳bj鏂囦歡鐨勯泦鍚?錛屼絾闈欐侀摼鎺ュ悗錛屾墽琛岀▼搴忎腑瀛樺湪鑷繁鎵闇obj鐨勪竴浠芥嫹璐濓紝鑰屽姩鎬侀摼鎺ュ悗錛屾墽琛岀▼搴忎粎浠呮槸鍖呭惈瀵瑰叡浜簱鐨勪竴涓紩鐢ㄣ傚叡浜簱鐩稿綋浜庝竴涓敱澶氫釜obj鏂囦歡緇勫悎鑰屾垚鐨刼bj鏂囦歡錛屽湪閾炬帴鍚庡叾鎵鏈変唬鐮佽鍔犺澆錛屼笉綆¢渶瑕佺殑榪樻槸涓嶉渶瑕佺殑銆?/span>
浼間箮鍙互寰楀嚭涓涓粨璁猴細
  闈欐侀摼鎺ュ悗鐨勭▼搴忔瘮鍔ㄦ侀摼鎺ョ殑鎵鐢ㄥ瓨鍌ㄧ┖闂村ぇ錛屽洜涓烘墽琛岀▼搴忎腑鍖呭惈浜嗗簱涓唬鐮佹嫹璐濓紱
  鑰屽姩鎬侀摼鎺ョ殑紼嬪簭姣旈潤鎬侀摼鎺ョ殑鎵鐢ㄧ殑榪愯絀洪棿澶э紝鍥犱負瀹冨皢涓嶉渶瑕佺殑浠g爜涔熷姞杞藉埌榪愯絀洪棿銆?/span>


閽堝涓婇潰鐨勭煡璇? 涓棶棰橈細

1錛?DLL鍜?LIB鏂囦歡蹇呴』闅忓簲鐢ㄧ▼搴忎竴璧峰彂琛岋紝鍚﹀垯搴旂敤紼嬪簭灝嗕細浜х敓閿欒銆?nbsp;
鎴戠殑絳旀錛歭ib搴旇涓嶉渶瑕佸惂銆?br />
2錛夊鏋滄槸鏌愪釜紼嬪簭涓皟鐢ㄤ簡涓涓姩鎬佸簱錛堥氳繃header鏂囦歡錛宭ib+dll鏉ヨ皟鐢級錛屽垯瀵瑰姩鎬佸簱鐨勬煇涓嚱鏁扮殑鍐呭淇敼浜嗭紝浣嗘帴鍙d笉鏀癸紝鍒欒皟鐢ㄦ鍔ㄦ佸簱鐨勭▼搴忛渶閲嶆柊緙栬瘧榪炴帴鍚楋紵濡傛灉鏄氳繃loadlibary鍔ㄦ佸姞杞斤紝闇瑕侀噸鏂扮紪璇戣繛鎺ュ悧錛?br />

鎴戠殑絳旀錛氶氳繃header+lib+dll璋冪敤鐨勮瘽闇瑕侀噸鏂扮紪璇戣繛鎺ワ紝浣嗘槸閫氳繃loadlibrary鏉ヤ嬌鐢ㄧ殑璇濓紝涓嶉渶瑕侀噸鏂扮紪璇戣繛鎺ャ?/span>
絎?涓瓟妗堥敊浜?搴旇鏄笉闇瑕侀噸鏂扮紪璇?鎺ュ彛涓嶅彉鐨勮瘽 .lib閮戒笉鐢ㄦ洿鏂?br />From: http://www.shnenglu.com/mzty/archive/2010/11/28/134901.html

    1錛?鑺傜渷鍐呭瓨銆傚悓涓涓蔣浠舵ā鍧楋紝鑻ユ槸浠ユ簮浠g爜鐨勫艦寮忛噸鐢紝鍒欎細琚紪璇戝埌涓嶅悓鐨勫彲鎵ц紼嬪簭涓紝鍚屾椂榪愯榪欎簺exe鏃惰繖浜涙ā鍧楃殑浜岃繘鍒剁爜浼氳閲嶅鍔犺澆鍒板唴瀛樹腑銆傚 鏋滀嬌鐢╠ll,鍒欏彧鍦ㄥ唴瀛樹腑鍔犺澆涓嬈★紝鎵鏈変嬌鐢ㄨdll鐨勮繘紼嬩細鍏變韓姝ゅ潡鍐呭瓨錛堝綋鐒訛紝鍍廳ll涓殑鍏ㄥ眬鍙橀噺榪欑涓滆タ鏄細琚瘡涓繘紼嬪鍒朵竴浠界殑錛夈?/span>
    
    2錛?涓嶉渶緙栬瘧鐨勮蔣浠剁郴緇熷崌綰э紝鑻ヤ竴涓蔣浠剁郴緇熶嬌鐢ㄤ簡dll,鍒欒dll琚敼鍙橈紙鍑芥暟鍚嶄笉鍙橈級鏃訛紝緋葷粺鍗囩駭鍙渶瑕佹洿鎹㈡dll鍗沖彲錛屼笉闇瑕侀噸鏂扮紪璇戞暣涓郴緇熴備簨瀹炰笂錛屽緢澶氳蔣浠墮兘鏄互榪欑鏂瑰紡鍗囩駭鐨勩備緥濡傛垜浠粡甯哥帺鐨勬槦闄呫侀瓟鍏界瓑娓告垙涔熸槸榪欐牱榪涜鐗堟湰鍗囩駭鐨勩?/span>
    
    3錛?Dll搴撳彲浠ヤ緵澶氱緙栫▼璇█浣跨敤錛屼緥濡傜敤c緙栧啓鐨刣ll鍙互鍦╲b涓皟鐢ㄣ傝繖涓鐐逛笂DLL榪樺仛寰楀緢涓嶅錛屽洜姝ゅ湪dll鐨勫熀紜涓婂彂鏄庝簡COM鎶鏈紝鏇村ソ鐨勮В鍐充簡涓緋誨垪闂銆?/span>

 

 



]]>
C錛嬶紜錛欳++ 鐨勬寚閽堝拰鍙ユ焺http://www.shnenglu.com/biao/archive/2012/08/07/186558.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Tue, 07 Aug 2012 04:44:00 GMThttp://www.shnenglu.com/biao/archive/2012/08/07/186558.htmlhttp://www.shnenglu.com/biao/comments/186558.htmlhttp://www.shnenglu.com/biao/archive/2012/08/07/186558.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/186558.htmlhttp://www.shnenglu.com/biao/services/trackbacks/186558.html1銆佸彞鏌勶紝鏄暣涓獁indows緙栫▼鐨勫熀紜銆備竴涓彞鏌勬槸鎸囦嬌鐢ㄥ敮涓鐨勬暣鏁板鹼紝鍗充竴涓洓瀛楄妭闀跨殑鏁板鹼紝鏉ユ爣蹇楀簲鐢ㄧ▼搴忎腑鐨勪笉鍚屽璞″拰鍚岀被瀵硅薄涓殑涓嶅悓瀹炰緥銆傚簲鐢ㄧ▼搴忛氳繃鍙ユ焺璁塊棶鐩稿簲瀵硅薄鐨勪俊鎭紝浣嗘槸鎹茍涓嶆槸鎸囬拡錛屼笉鑳界洿鎺ラ氳繃瀹冩潵闃呰鏂囦歡涓殑淇℃伅銆?/div>
 2銆佸浜巆++涓殑鍙ユ焺鍜屾寚閽堝鏄撴販娣嗐?/div>
    鎸囬拡錛氫粬鏄唴瀛樼殑緙栧彿錛岄氳繃瀹冩垜浠彲浠ョ洿鎺ュ鍐呭瓨榪涜鎿嶄綔錛屽彧瑕佸湴鍧涓嶅彉錛屾垜浠搷浣滅殑鐗╃悊鍦板潃涓氱晫涓嶅彉銆?---涓庡彞鏌勭殑閲嶅ぇ鍖哄埆銆?/div>
   鍙ユ焺錛氫竴鑸槸鎸囧悜緋葷粺璧勬簮鐨勪綅緗紝涔熷彲浠ヨ鏄湴鍧錛屼絾鏄繖浜涘湴鍧涓鐩翠繚鎸佷笉鍙樸傚叾瀹烇紝瀵逛簬windows 緋葷粺鏉ヨ鏀寔鐨勬槸铏氭嫙鍐呭瓨鐨勬妧鏈紝緇熶竴鏃墮棿鍐呭彲鑳芥湁浜涜祫婧愯鎹㈠嚭錛屾湁浜涜祫婧愯鎹㈣繘鏉ャ傚洜姝ゅ悓涓涓祫婧愬湪涓嶅悓鐨勬椂鍒葷墿鐞嗕綅緗槸涓嶅悓鐨勩倃indow灝辨槸閫氳繃鍙ユ焺鏉ュ鐞嗗悓涓璧勬簮鐗╃悊浣嶇疆涓嶆柇鍙樺寲鐨勯棶棰樸傚湪window涓浐瀹氱殑浣嶇疆瀛樺偍浜嗕竴寮犺〃錛氳褰曚簡鎵鏈夎祫婧愮殑瀹炴椂鍦板潃錛屽彞鏌勫叾瀹炴病鏈夌洿鎺ユ寚鍚戣祫婧愮殑鐗╃悊鍦板潃錛岃屾槸鎸囧悜瀵瑰簲琛ㄤ腑鐨勬煇涓欏癸紝榪欐牱鏃犺璧勬簮鐨勭墿鐞嗗湴鍧鎬庝箞鎹紝閫氳繃鍙ユ焺閮藉彲浠ュ疄鏃剁殑鎵懼埌浠栫殑瀹炴椂浣嶇疆銆?/div>

From: http://blog.chinaunix.net/uid-26874138-id-3302108.html
@import url(http://www.shnenglu.com/cutesoft_client/cuteeditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

]]>鍏朵粬緙栫▼錛氱増鏈帶鍒跺叆闂ㄧ畝浠?/title><link>http://www.shnenglu.com/biao/archive/2012/04/27/172924.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Fri, 27 Apr 2012 07:07:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2012/04/27/172924.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/172924.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2012/04/27/172924.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/172924.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/172924.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Verdana; text-align: left; background-color: #e5ecf4; ">鐗堟湰鎺у埗宸茬粡鍑虹幇鏈変簺騫村ご浜嗐傜劧鑰岋紝鎴戣繕鏄細琚漢闂搗涓浜涳紝璇稿鐗堟湰鎺у埗鏄粈涔堟垨鑰呭畠鏄浣曞伐浣滅殑錛岃繖鏍峰熀紜鐨勯棶棰樸傛湰鏂囦細姒傛嫭鍦拌В閲婄増鏈帶鍒惰В鍐崇殑閲嶈闂錛屾湰鏂囦嬌鐢ㄧ殑鍦烘櫙閽堝鐨勬槸婧愪唬鐮佺増鏈帶鍒躲?/p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Verdana; text-align: left; background-color: #e5ecf4; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鐩墠鏈夊緢澶氫笉鍚岀被鍨嬬殑鐗堟湰鎺у埗緋葷粺錛圴ersion Control System錛?VCS錛夈備竴浜沄CS錛屾瘮濡?a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">Subversion</a>鍜?a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">CVS</a>錛屼互涓ぎ浠撳簱錛坮epository錛変負涓績榪涜鏋舵瀯銆傛澶栵紝榪樻湁鍒嗗竷寮忕殑VCS錛圖istributed VCS錛孌VCS錛夛紝 <a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">Git</a> 鍜?nbsp;<a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">Mercurial</a> 鏄袱涓柊榪戝嚭鐜扮殑DVCS銆傜劧鑰岋紝鍦ㄤ笂榪頒袱縐嶇被鍨嬬殑鐜涓紝閫氬父浼氭湁涓涓?#8220;鎸囧畾鐨?#8221;涓ぎ浠撳簱銆傚搴斿湴錛屾瘮濡備竴涓猄ubversion鏈嶅姟鍣ㄦ垨鑰呬竴涓?a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">GitHub</a>浠撳簱銆備笅闈細鍩轟簬榪欎釜鍦烘櫙榪涜鍥劇ず璇存槑銆傞偅涔堣鎴戜滑寮濮嬪惂銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鍦ㄥ紑鍙戣呮嫹璐濆埌鏈満涔嬪墠錛屾湇鍔″櫒闇瑕佸垱寤轟竴涓粨搴撱傚垱寤哄垵濮嬩粨搴撲細鐢變簬浜у搧涓嶅悓鑰屾湁鎵宸埆銆備粠鐜板湪璧鳳紝浣犳墍瑕佺煡閬撶殑灝辨槸錛屽湪鏈嶅姟鍣ㄤ笂鏈変竴涓垵濮嬬┖闂淬傛垜鎶婅繖涓増鏈О浣滅増鏈?#8220;A”銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS1" src="http://img.cnbeta.com/newsimg/120427/08104301990317868.png" altwidth="237" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鐜板湪錛屾瘡涓紑鍙戣咃紙寮鍙戣?鍜屽紑鍙戣?錛夐兘浼氭嫹璐濈増鏈?#8220;A”鍒頒粬浠湰鍦扮數鑴戙傚啀涓嬈″湴錛屼粠鏈嶅姟鍣ㄦ嫹璐濈殑榪囩▼浼氱敱浜庝駭鍝佷笉鍚岄噰鐢ㄧ殑鎶鏈細鏈夋墍宸埆銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS2" src="http://img.cnbeta.com/newsimg/120427/0810451132929552.png" altwidth="243" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />姣忎釜寮鍙戣呬細鍦ㄤ粬浠殑鏈湴鎷瘋礉涓婅繘琛屽紑鍙戙備粬浠殑鏈湴鎷瘋礉鍩轟簬鐗堟湰“A”銆傜劧鑰岋紝鐢變簬浠栦滑<em style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">搴旇涓嶄細</em>鍋氬悓鏍風殑寮鍙戯紝鍥犺屼粬浠殑鐗堟湰浼氭湁鎵宸埆銆傚洜姝わ紝浼氭湁2涓互涓婄殑鐗堟湰浼氬悓鏃惰鍒涘緩錛屾瘮濡傜増鏈?#8220;B”鍜岀増鏈?#8220;C”銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS3" src="http://img.cnbeta.com/newsimg/120427/08104621156274916.png" altwidth="317" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />寮鍙戣?棣栧厛瀹屾垚浜嗗ス鐨勫伐浣滃茍鎻愪氦鍒版湇鍔″櫒銆傛湇鍔″櫒涓婄殑褰撳墠鐗堟湰琚洿鏂版垚鐗堟湰“B”銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS4" src="http://img.cnbeta.com/newsimg/120427/08104831137474324.png" altwidth="317" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />寮鍙戣?鐜板湪瀹屾垚浜嗕粬鐨勫伐浣滃茍璇曞浘鎻愪氦鍒版湇鍔″櫒銆傜劧鑰岋紝榪欐槸鏈嶅姟鍣ㄥ憡鐭ヤ粬鍩轟簬寮鍙戠殑鐗堟湰宸茬粡鍙戠敓鏀瑰彉銆?strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">榪欎篃鏄負浠涔堥噰鍙栫増鏈帶鍒剁殑棣栬鍘熷洜涔嬩竴銆?/strong>榪欎釜鐗規ф槸瀵圭綉緇滃叡浜唬鐮佺劧鍚庣敱寮鍙戣呮墜鍔ㄦ洿鏂扮殑涓涓法瓚婂紡鍙戝睍錛岃繖紜繚浜嗕箣鍓嶇殑緙栬緫娌℃湁琚柊鐨勪慨鏀硅鐩栥?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS5" src="http://img.cnbeta.com/newsimg/120427/08104941810307228.png" altwidth="396" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />寮鍙戣?蹇呴』棣栧厛鑾峰緱鎵鏈夌増鏈?#8220;B”鐨勫彉鍖栵紝騫跺悎騫跺埌浠栫殑淇敼涓紝鐒跺悗鎵嶅彲浠ユ彁浜ゅ埌鏈嶅姟鍣ㄣ傝繖涓繃紼嬪惉璧鋒潵鏈変簺澶嶆潅銆傜劧鑰岋紝澶у鏁扮幇浠g殑鐗堟湰鎺у埗緋葷粺鍗佸垎楂樼駭錛岃兘澶熻嚜鍔ㄥ湪寮鍙戣呯殑鏈湴鎷瘋礉涓婂畬鎴愬悎騫躲傛湁鍑犵鎯呭喌浼氫駭鐢熷啿紿侊紙渚嬪錛氬紑鍙戣?鍜屽紑鍙戣?鍚屾椂淇敼浜嗗悓涓涓枃浠剁殑鍚屼竴琛岋級銆傝繖灝辨槸涓浜沄CS浜у搧姣斿叾浠栨洿楂樼駭鐨勫湴鏂廣備笉璁哄浣曞畬鎴愬悎騫訛紝鐜板湪寮鍙戣?鍦ㄤ粬浠殑鏈湴緋葷粺涓婂悓鏃舵販鍚堜簡鐗堟湰B鍜岀増鏈珻銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS6" src="http://img.cnbeta.com/newsimg/120427/0810515916028618.png" altwidth="459" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鐜板湪寮鍙戣?鍙互鎻愪氦浠栫殑鐗堟湰鍒版湇鍔″櫒銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /><a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; "><img title="VCS7" src="http://img.cnbeta.com/newsimg/120427/08105262025047221.png" altwidth="410" style="margin-top: 5px !important; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: initial; border-color: initial; border-image: initial; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; clear: both; display: block; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-top-left-radius: 6px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; border-top-color: #d4d4d4; border-right-color: #d4d4d4; border-bottom-color: #d4d4d4; border-left-color: #d4d4d4; " alt="" /></a><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />榪欐槸涓涓増鏈帶鍒剁殑鍩虹銆傞氳繃娉ㄦ剰瑙傚療鍥句腑鏈嶅姟鍣ㄧ殑榪炵嚎鍙互鍙戠幇鐗堟湰鎺у埗鐨勫師鐞嗐傛湇鍔″櫒璁板綍浜嗘墍鏈夊厛鍓嶇殑鐗堟湰鍖呮嫭鍙戠敓鐨勫彉鍖栵紝浠涔堟椂鍊欏彂鐢熶互鍙婄敱璋佽繘琛屼慨鏀廣傚綋闇瑕佽繘琛屼唬鐮佸洖婧垨鑰呭紩鍏ュ叾浠朾ug鏃訛紝榪欎釜璁板綍鑳藉瑙i櫎鍥板銆?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鎴戝笇鏈涙湰鏂囪兘澶熶負鐗堟湰鎺у埗緋葷粺鎻愪緵涓涓熀紜鐨勪粙緇嶃傚鏋滀綘鏈変換浣曠枒闂紝璇峰氨浣犻棶棰樺彂琛ㄨ瘎璁恒?br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /> <br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />鑻辨枃鍘熸枃錛?a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">greenmoonsoftware </a>緙栬瘧錛?a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">浼箰</a>鍦ㄧ嚎 – <a style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #003366; text-decoration: none; ">鍞愬挨鍗?/a></p><img src ="http://www.shnenglu.com/biao/aggbug/172924.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2012-04-27 15:07 <a href="http://www.shnenglu.com/biao/archive/2012/04/27/172924.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++錛氫綅鎿嶄綔鍩虹綃囦箣浣嶆搷浣滃叏闈㈡葷粨http://www.shnenglu.com/biao/archive/2012/03/20/168357.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Mon, 19 Mar 2012 23:01:00 GMThttp://www.shnenglu.com/biao/archive/2012/03/20/168357.htmlhttp://www.shnenglu.com/biao/comments/168357.htmlhttp://www.shnenglu.com/biao/archive/2012/03/20/168357.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/168357.htmlhttp://www.shnenglu.com/biao/services/trackbacks/168357.html闃呰鍏ㄦ枃

]]>
C++錛氫簩緇存暟緇勫拰浜岀駭鎸囬拡鐨勪紶閫掗棶棰?/title><link>http://www.shnenglu.com/biao/archive/2012/01/12/164030.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Thu, 12 Jan 2012 01:30:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2012/01/12/164030.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/164030.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2012/01/12/164030.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/164030.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/164030.html</trackback:ping><description><![CDATA[     鎽樿: 鍐嶆鐪嬭繖綃囨枃绔狅紝鎰熻璇寸殑濂藉閮芥槸搴熻瘽錛屽湪鏂囩珷鏈鍓嶉潰琛ュ厖涓鍙ヨ瘽錛?“[]鐨勪紭鍏堢駭楂樹簬*”錛屽ぇ瀹跺彲浠ュ甫鐫榪欏彞璇濈湅涓嬮潰鐨剘~~ ======================== 鍐嶄竴嬈$殑瑙佽瘉浜嗚嚜宸辯殑鍩虹涓嶇墷闈犮傘傘傚垢濂藉彂鐜板緱鏃╋紝鐪嬭緗戜笂璇達紝鍗庝負鐨勪竴涓潰璇曢灝辮冧簡榪欎釜鏂歸潰鐨勩?鍊熼偅閬撳崕涓虹殑闈㈣瘯棰樺紩鍑洪棶棰橈紝棰樼洰錛?char **p, a[16][8];  闂細p=...  <a href='http://www.shnenglu.com/biao/archive/2012/01/12/164030.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/biao/aggbug/164030.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2012-01-12 09:30 <a href="http://www.shnenglu.com/biao/archive/2012/01/12/164030.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++錛氭誕鐐規暟鐨勫瓨鍌ㄦ柟寮?/title><link>http://www.shnenglu.com/biao/archive/2011/12/18/162330.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Sun, 18 Dec 2011 03:20:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2011/12/18/162330.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/162330.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2011/12/18/162330.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/162330.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/162330.html</trackback:ping><description><![CDATA[<span style="font-family: simsun; line-height: 23px; ">float鍐呭瓨瀛樺偍緇撴瀯(鍏?瀛楄妭錛?2浣嶅垎鍒涓?錛?br /> 31 30 29----23 22----0   <br /> <br /> 瀹炴暟絎﹀彿浣?鎸囨暟絎﹀彿浣?鎸囨暟浣?鏈夋晥鏁頒綅<br /> 鍏朵腑瀹炴暟絎﹀彿浣?琛ㄧず姝o紝1琛ㄧず璐燂紱鎸囨暟絎﹀彿浣?琛ㄧず姝o紝0琛ㄧず璐?br /> <br /> float鍦ㄨ綆楁満涓殑瀛樺偍璁$畻鏂規硶錛?br /> 1. 鍏堝皢榪欎釜瀹炴暟鐨勭粷瀵瑰煎寲涓轟簩榪涘埗鏍煎紡錛屾柟娉曟槸錛氬疄鏁扮殑鏁存暟閮ㄥ垎鏄櫎2鍙栦綑鍜屽皬鏁伴儴鍒嗘槸涔?鍙栨暣<br /> 2. 灝嗚繖涓簩榪涘埗鏍煎紡瀹炴暟鐨勫皬鏁扮偣宸︾Щ鎴栧彸縐籲浣嶏紝鐩村埌灝忔暟鐐圭Щ鍔ㄥ埌絎竴涓湁鏁堟暟瀛楃殑鍙寵竟銆?br /> 3. 浠庡皬鏁扮偣鍙寵竟絎竴浣嶅紑濮嬫暟鍑轟簩鍗佷笁浣嶆暟瀛楁斁鍏ョ22鍒扮0浣嶃?br /> 4. 濡傛灉瀹炴暟鏄鐨勶紝鍒欏湪絎?1浣嶆斁鍏?#8220;0”錛屽惁鍒欐斁鍏?#8220;1”銆?br /> 5. 濡傛灉n 鏄乏縐誨緱鍒扮殑錛岃鏄庢寚鏁版槸姝g殑錛岀30浣嶆斁鍏?#8220;1”銆傚鏋渘鏄彸縐誨緱鍒扮殑鎴杗=0錛屽垯絎?0浣嶆斁鍏?#8220;0”銆?br /> 6. 濡傛灉n鏄乏縐誨緱鍒扮殑錛屽垯灝唍鍑忓幓1鍚庡寲涓轟簩榪涘埗錛屽茍鍦ㄥ乏杈瑰姞“0”琛ヨ凍涓冧綅錛屾斁鍏ョ29鍒扮23浣嶃傚鏋渘鏄彸縐誨緱鍒扮殑鎴杗=0錛?br /> <br /> 鍒欏皢n鍖栦負浜岃繘鍒跺悗鍦ㄥ乏杈瑰姞“0”琛ヨ凍涓冧綅錛屽啀鍚勪綅姹傚弽錛屽啀鏀懼叆絎?9鍒扮23浣嶃?nbsp; <br /> <br /> 鏍規嵁涓婇潰閭d釜姝ラ寰楋細<br /> (1). 23.172001浜岃繘鍒跺艦寮忎負錛?001,0111.0010,1100,0000,1000,0100,0001....<br /> (2)宸︾Щ4浣嶅緱錛?.0111.0010,1100,0000,1000,0100,0001<br /> (3)鍙栧皬鏁扮偣鍚?3浣嶅緱錛?0111.0010,1100,0000,1000,010錛堣繖23浣嶄負float鏁頒簩榪涘埗鐮佺殑鍚?3浣嶏級<br /> (4)絎?1浣嶏細 0<br /> (5)絎?0浣嶏細 1<br /> (6)宸︾Щ4浣嶏紝4鐨勪簩榪涘埗0011錛屼笉瓚?浣嶅垯錛?000,011<br /> 鏈鍚庡緱23.172001鍦ㄨ綆楁満涓殑浜岃繘鍒惰〃鐜板艦寮忎負錛?100,0001,1011,1001,0110,0000,0100,0010<br /> 浜岃繘鍒惰漿16榪涘埗寰楋細41A96042</span> @import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); <div><span style="font-family: simsun; line-height: 23px; "><br /> </span></div> <div><span style="font-family: simsun; line-height: 23px; ">From: http://topic.csdn.net/u/20111217/19/6c5221d6-a779-4e6c-9eb0-72949857dc6e.html?95401</span></div><img src ="http://www.shnenglu.com/biao/aggbug/162330.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2011-12-18 11:20 <a href="http://www.shnenglu.com/biao/archive/2011/12/18/162330.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C/C++錛氭竻絀鴻緭鍏ョ紦鍐插尯http://www.shnenglu.com/biao/archive/2010/12/17/136791.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:17:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136791.htmlhttp://www.shnenglu.com/biao/comments/136791.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136791.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136791.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136791.htmlint main(int argc, char *argv[]) {
    std::string str1, str2;
    
    std::cin >> str1;
    std::cin.sync();
    std::cin >> str2;
    
    std::cout << str1 << std::endl << str2 << std::endl;
    //fflush(stdin);
    
    return EXIT_SUCCESS;
}

int main(int argc, char *argv[]) {
    int v = 0;

    while (std::cin >> v) {
        std::cout << v << std::endl;
    }

    // The order clear() and sync() is very important.
    // Clear the input stream's state
    // and then clear the input stream's content
    // to input new string.
    std::cin.clear();
    std::cin.sync();

    std::string str;
    std::cin >> str;
    std::cout << str << std::endl;

    std::cout << v << std::endl;

    return EXIT_SUCCESS;
}

]]>
C/C++錛氬伔鎳掔殑qsort and bsearchhttp://www.shnenglu.com/biao/archive/2010/12/17/136788.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:13:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136788.htmlhttp://www.shnenglu.com/biao/comments/136788.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136788.html#Feedback1http://www.shnenglu.com/biao/comments/commentRss/136788.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136788.html
鍒╃敤C鏍囧噯搴撳嚱鏁版彁渚涚殑蹇熸帓搴忓拰浜屽垎鏌ユ壘娉曟潵榪涜鎺掑簭鍜屾煡鎵?鍙渶瑕佽嚜瀹氫箟涓涓瘮杈冨嚱鏁板嵆鍙?
   #include <stdlib.h>  void qsort( void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) );
鍔熻兘錛?/span> 瀵?/span>buf 鎸囧悜鐨勬暟鎹?/span>(鍖呭惈num 欏?/span>,姣忛」鐨勫ぇ灝忎負size)榪涜蹇熸帓搴忋傚鏋滃嚱鏁?/span>compare 鐨勭涓涓弬鏁板皬浜庣浜屼釜鍙傛暟錛岃繑鍥炶礋鍊鹼紱濡傛灉絳変簬榪斿洖闆跺鹼紱濡傛灉澶т簬榪斿洖姝e箋傚嚱鏁板buf 鎸囧悜鐨勬暟鎹寜鍗囧簭鎺掑簭銆?/span>
 
   #include <stdlib.h>  void *bsearch( const void *key, const void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) );
鍔熻兘錛?/span> 鍑芥暟鐢ㄦ姌鍗婃煡鎵炬硶鍦ㄤ粠鏁扮粍鍏冪礌buf[0]鍒?/span>buf[num-1] 鍖歸厤鍙傛暟key銆傚鏋滃嚱鏁?/span>compare 鐨勭涓涓弬鏁板皬浜庣浜屼釜鍙傛暟錛岃繑鍥炶礋鍊鹼紱濡傛灉絳変簬榪斿洖闆跺鹼紱濡傛灉澶т簬榪斿洖姝e箋傛暟緇?/span>buf 涓殑鍏冪礌搴斾互鍗囧簭鎺掑垪銆傚嚱鏁?/span>bsearch()鐨勮繑鍥炲兼槸鎸囧悜鍖歸厤欏癸紝濡傛灉娌℃湁鍙戠幇鍖歸厤欏癸紝榪斿洖NULL銆?/span>
 

struct Company {
        char number[9];
        char name[41];
        char name_jp[31];
        char region[9];
        char address[51];
        char telephonNumber[14]; // 鍥犱負鐢佃瘽鍙風爜鍚庤繕璺熶簡涓涓洖杞︼紝鎵浠ュ緱鍐嶅鍔狅紤
};

int compare(const void* company1, const void* company2) {
        return strcmp(((struct Company*)company1)->number, ((struct Company*)company2)->number);
}

const struct Company* search(const char* number,
                const struct Company* companys,
                int numberOfCompanys) {
        int compare(const void* company1, const void* company2);
        struct Company tempCompany;
        int low = 0;
        int height = numberOfCompanys - 1;
        int middle = 0;
        if ((strlen(number) > 8) || (numberOfCompanys < 1) ||(companys == NULL) || (number == NULL)) {
                return NULL;
        }
        strcpy(tempCompany.number, number); // 鏋勯犱竴涓復鏃跺叕鍙哥粨鏋勪綋,鐢ㄤ簬姣旇緝鍑芥暟compare鐢?
        /*while (low <= height) {
         middle = (low + height) / 2;
         if (compare(&tempCompany, &companys[middle])> 0) {
         low = middle + 1;
         } else if (compare(&tempCompany, &companys[middle])< 0) {
         height = middle - 1;
         } else if (compare(&tempCompany, &companys[middle])== 0) {
         return &companys[middle];
         }
         }
         return NULL;*/
        return (struct Company*)bsearch(&tempCompany, companys, numberOfCompanys, sizeof(struct Company),
                        compare);
}

void sort(struct Company* companys, int numberOfCompanys) {
        int compare(const void* company1, const void* company2); // 蹇熸帓搴忓嚱鏁皅sort闇瑕佺殑姣旇緝鍑芥暟
        qsort(companys, numberOfCompanys, sizeof(struct Company), compare); // 璋冪敤緋葷粺鎻愪緵鐨勫揩閫熸帓搴忚繘琛屾帓搴?
}

 



]]>
C/C++錛氬懡浠よ杈撳叆涓嶅洖鏄?/title><link>http://www.shnenglu.com/biao/archive/2010/12/17/136787.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Fri, 17 Dec 2010 10:12:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2010/12/17/136787.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/136787.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2010/12/17/136787.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/136787.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/136787.html</trackback:ping><description><![CDATA[<span style="line-height: 15px; color: rgb(0, 134, 198); font-family: 'BBAlpha Sans', 'Prelude Medium', 'S60 Sans', Tahoma, Verdana, Arial, sans-serif; font-size: 12px; "><div style="line-height: 15px; ">#include <iostream><br style="line-height: 15px; ">#include <conio.h></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">/**<br style="line-height: 15px; "> * 縐樺瘑鍦ㄤ簬conio.h涓殑getch()浠庨敭鐩樹腑璇誨彇瀛楃鏃?騫朵笉浼氬湪灞忓箷涓婅緭鍑哄凡緇忚緭鍏ョ殑瀛楃,<br style="line-height: 15px; "> * 鑰岀敤涓涓猵utch('*')鏉ュ搫楠?浠h〃宸茬粡杈撳叆涓涓瓧絎?br style="line-height: 15px; "> * 鎬笉寰楄繖涓ご鏂囦歡瑕佸彨conio.h, con鐨勬剰鎬濆氨鏈夊搫楠?鐪嬫潵灝辨槸鐢辨鑰屾潵.<br style="line-height: 15px; "> */</font></div><div style="line-height: 15px; ">using namespace std;</div><div style="line-height: 15px; ">int main() {<br style="line-height: 15px; ">        char* password;<br style="line-height: 15px; ">        char* passwordConfirm;</div><div style="line-height: 15px; ">        int length = 4;<br style="line-height: 15px; ">        password = new char[length + 1];<br style="line-height: 15px; ">        passwordConfirm = new char[length + 1];</div><div style="line-height: 15px; ">        char* p = NULL;<br style="line-height: 15px; ">        int count = 0;</div><div style="line-height: 15px; ">        cout << "Input password : ";<br style="line-height: 15px; ">        p = password;<br style="line-height: 15px; ">        count = 0;<br style="line-height: 15px; ">        //fflush(stdin);<br style="line-height: 15px; ">        while (((*p = getch()) != 13) && count < length) {<br style="line-height: 15px; ">                <font color="#00ff00" style="line-height: normal; ">// 榪欓噷涓嶆槸'\n'(10), new line<br style="line-height: 15px; ">                // 鑰屾槸'\r'(13), reback. 鍗蟲槸鎸変笅鍥炶濺閿?濂藉儚榪欎釜涓滆タ鏄痩inux鐨?<br style="line-height: 15px; ">                // 涓昏鏄笌getch榪欎釜鍑芥暟鏈夊叧.<br style="line-height: 15px; "></font>                putch('*');<br style="line-height: 15px; ">                fflush(stdin);</div><div style="line-height: 15px; ">                p++;<br style="line-height: 15px; ">                count++;<br style="line-height: 15px; ">        }<br style="line-height: 15px; ">        password[count] = '\0';</div><div style="line-height: 15px; ">        cout << endl << "Confirm the password : ";<br style="line-height: 15px; ">        p = passwordConfirm;<br style="line-height: 15px; ">        count = 0;<br style="line-height: 15px; ">        //fflush(stdin);<br style="line-height: 15px; ">        while (((*p = getch()) != 13) && count < length) {<br style="line-height: 15px; ">                putch('*');<br style="line-height: 15px; ">                fflush(stdin);</div><div style="line-height: 15px; ">                p++;<br style="line-height: 15px; ">                count++;<br style="line-height: 15px; ">        }<br style="line-height: 15px; ">        passwordConfirm[count] = '\0';</div><div style="line-height: 15px; ">        cout << endl;<br style="line-height: 15px; ">        if (strcmp(password, passwordConfirm) == 0) {<br style="line-height: 15px; ">                cout << "The password is right." << endl;<br style="line-height: 15px; ">                cout << password << endl;<br style="line-height: 15px; ">        } else {<br style="line-height: 15px; ">                cout << "Confirm password fail." << endl;<br style="line-height: 15px; ">                cout << password << endl << passwordConfirm << endl;<br style="line-height: 15px; ">        }</div><div style="line-height: 15px; ">        return 0;<br style="line-height: 15px; ">}</div></span> <img src ="http://www.shnenglu.com/biao/aggbug/136787.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2010-12-17 18:12 <a href="http://www.shnenglu.com/biao/archive/2010/12/17/136787.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C/C++錛氳鍙栨枃浠跺皬緇嗚妭http://www.shnenglu.com/biao/archive/2010/12/17/136786.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:11:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136786.htmlhttp://www.shnenglu.com/biao/comments/136786.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136786.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136786.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136786.html
浠ワ跡涓鏂囦歡鏃訛紝瑕侀潪甯稿皬蹇冿紝鐢ㄤ簩榪涘埗澶勭悊鍜岀敤鏂囨湰鏂瑰紡澶勭悊錛屽浜庣敤鏂囨湰鏂瑰紡鍐欏叆鐨勬枃浠訛紝鎿嶄綔緇撴灉鏄浉鍚岀殑錛屼絾鏄浜庣敤浜岃繘鍒跺啓鍏ョ殑鏂囦歡錛岀粨鏋滃嵈鏄ぇ涓轟笉鍚?渚嬪鐢ㄥ叾瀵?exe鏂囦歡榪涜璇誨彇錛?/font>
#include <iostream>
#include <ctime>
#include <fstream>
using namespace std;
int main(){
        FILE* fp;
        fp = fopen("d.txt", "wb");
        char* str = "biao";
        fwrite(str, strlen(str), 1, fp);
        fclose(fp);
        
        fp = fopen("test.exe", "rb");
        fseek(fp, 0L, SEEK_END);
        int length = ftell(fp);
        cout << "File length: " << length << endl;
        
        rewind(fp);
        char ch;
        int count = 0;
        while (!feof(fp)) {
                ch = fgetc(fp);
                //cout << ch;
                count++;
        }
        cout << endl << count << endl;
        cout << (int)ch << endl;
        cout << ftell(fp) << endl;
        
        fclose(fp);
        return 0;
}
 
鏂囦歡闀垮害鏄?76268錛屽綋鐢╮b鏃訛紝while (!feof(fp))鑳芥甯哥殑璇誨埌鏂囦歡鏈紝浣嗘槸濡傛灉鐢╮鏉ヨ鍙栵紝鍒版渶鍚庯紝ftell(fp)錛屾濂芥槸鏂囦歡鐨勯暱搴︼紝浣嗙敤r鏃訛紝while (!feof(fp))騫朵笉鑳藉埌杈炬枃浠跺熬錛屾渶鍚巉tell(fp)鐨勫兼槸7859,鐩稿樊澶錛屽鍥劇墖鏂囦歡涔熸槸涓鏍風殑.涔熻瀵逛簬鐢╮鍜宺b鎵撳紑鐨勬枃浠舵搷浣滄椂錛屽浜巉eof(fp)鏉ュ垽鏂槸鍚﹀埌杈炬枃浠跺熬鏃剁殑鏂瑰紡涓嶄竴鏍? 鍗崇敤r鎵撳紑鏃訛紝feof(fp)鐨勫垽鏂槸褰撹鍙栭亣鍒癊OF鍗?1鏃訛紝鍒ゆ柇涓烘枃浠剁粨鏉燂紝娉ㄦ剰錛屽嵆浣挎槸鐢╮b鏂瑰紡鎵撳紑鏂囦歡錛屽鏋滃垽鏂殑鏃跺欎笉鐢╳hile(!feof(fp))鑰岀敤((ch = fgetc(fp)) != EOF)錛屼竴鏍風殑鏄鍙栭亣鍒癊OF鏃跺驚鐜氨涓嶄細緇х畫榪涜錛屽嵆EOF鍙傚悎浜庢枃鏈瘯錛屼絾feof(fp)鍗翠細鏍規嵁鏄敤鏂囨湰鏂瑰紡榪樻槸鐢ㄤ簩榪涘埗鏂瑰紡鏉ュ垽鏂嚜鍔ㄤ嬌鐢ㄤ笉鍚岀殑鍒ゆ柇鏄惁鍒拌揪鏂囦歡灝?
 
鎵浠ユ洿閫氱敤涓浜涚殑鍒ゆ柇鏂囦歡緇撴潫鏂瑰紡鐢╢eof.
 
閫氳繃瀵筬read(buf, size, num, fp)鐨勬祴璇曪紝褰搒ize * num鐩稿悓鏃訛紝濡?font color="#00ff00" style="line-height: normal; ">fread(buf, 255, 1, fp)涓巉read(buf, 1, 255, fp)鐨勯熷害鐩稿樊闈炲父灝忥紝璇誨彇210M鐨勪簩榪涘埗鏂囦歡鐢ㄤ簡9縐掑涓浜涳紙緙撳啿鍖鴻緗垚256B, 128, 256, 1024鏃剁殑閫熷害閮藉樊涓嶅錛屼絾鏄?00K鏃跺嵈鏄?3縐掞紝鐪嬫潵騫墮潪鏄紦鍐插尯瓚婂ぇ瓚婂ソ錛屼絾鏄紦鍐插尯澶ф椂錛屽彲浠ュ噺灝戝紜洏榪涜鎿嶄綔鐨勬鏁幫級.
 
濡傜敤rb(浜岃繘鍒舵柟寮?鎶婄粨鏋勪綋鐨勬暟鎹啓鍏ユ枃浠舵椂錛屼笉浼氫駭鐢熼澶栫殑鏁版嵁錛岀敤fseek(fp, 0L, SEEK_END), ftell(fp),鍙栧緱鐨勯暱搴︽濂芥槸緇撴瀯鐨勯暱搴︼紛涓暟錛屼絾鏄敤r(鏂囨湰鏂瑰紡)鎶婄粨鏋勪綋鐨勬暟鎹啓鍏ユ枃浠舵椂錛屽嵈浼氫駭鐢熶竴浜涘澶栫殑鏁版嵁錛屾鏃訛紝濡傛灉鎯充粠鏂囦歡涓粠鍚庡悜鍓嶈鍙栫粨鏋勪綋鐨勬暟鎹紝灝變笉鑳芥甯稿緱鍒版墍鏈夋暟鎹紝濂藉湪浠庡墠鍚戝悗璇繪病鏈夐棶棰?浠ラ槻涓囦竴錛屽簲璇ョ敤浜岃繘鍒舵柟寮忔潵鎿嶄綔錛岃繖鏍鳳紝鍗沖彲浠ヤ粠鍓嶅悜鍚庤錛屼篃鍙互浠庡悗鍚戝墠璇?鍦╢seek涓紝鍙互鐢ㄨ礋鏁版潵鐩稿浜庡綋鍓嶆枃浠舵寚閽堬紝鎶婃枃浠舵寚閽堝悜鍓嶇Щ鍔?fseek(fp, -sizeof(STRUCT), SEEK_CUR).



]]>
C/C++錛殈(~0 << 6)http://www.shnenglu.com/biao/archive/2010/12/17/136785.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:10:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136785.htmlhttp://www.shnenglu.com/biao/comments/136785.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136785.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136785.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136785.html
鎬庢牱浣垮緱涓涓暟浠庡彸鍚戝乏4~9浣嶅叏鏄?:
int a = 222222;
int temp = ~(~0 << 6);// ~0 浣跨敤鏁扮殑姣忎竴浣嶅叏涓?, 宸︾Щ鍏綅錛屼嬌寰楁渶鍙寵竟6浣嶅叏涓?, 鍐嶅彇鍙嶏紝渚嬪墠闈㈠叏涓?,鍚庨潰6浣嶄負1.
a >>= 4;
a &= temp;
a <<= 4;
 
32 bits binary nummer:
#include <iostream>
using namespace std;
int main() {
        int ref = 1 << 31;
        int a = 14;
        
        for (int i = 0; i < 32; i++) {
                cout << (a & ref? '1': '0');
                a <<= 1;
        }
        
        return 0;
}


]]>
Java錛氬己澶х殑Eclipsehttp://www.shnenglu.com/biao/archive/2010/12/17/136784.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:09:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136784.htmlhttp://www.shnenglu.com/biao/comments/136784.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136784.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136784.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136784.html
鍦‥clipse涓啓OpenGL, Qt, C, C++, Java, links鏂瑰紡瀹夎鎻掍歡錛屽鍏ュ伐紼嬶細
Java: Eclipse瑕佽繍琛屽湪jre鐨勭幆澧冧箣涓婏紝鑷甫Java鐜
C, C++:  涓嬭澆CDT錛屼笉鍚岀増鏈殑CDT涓庝笉鍚岀増鏈殑Eclipse鍖歸厤錛屽洜涓轟粬浠殑鏇存柊寰堝揩
 
瀹夎CDT鍜孍clipse鏃訛紝騫舵病鏈塁/C++緙栬瘧鍣紝寰楄嚜宸變笅涓涓紝瀵逛簬windows鏈変袱涓瘮杈冨ソ:Cygwin鍜孧inGW錛岄兘鏄嬌鐢↙inux涓嬬殑GCC windows縐繪鐗堬紝瀵規爣鍑嗘敮鎸侀潪甯稿ソ錛屼笉鍍弚indows鑷繁鐨勶紝鎼炲緱涔變竷鍏碂錛屼笉榪囨渶濂芥槸瀹夎MinGW錛屽洜涓哄ぇ澶氭暟閮芥槸鏀寔MinGW錛岃屼笖Qt鐨剋indows瀹夎鐗堟湰灝卞彧鏀寔MinGW錛屽鏋滆鐢–ygwin鐨勮瘽錛岄偅寰楄嚜宸辯紪璇慟t鐨勬簮鐮併傚畨瑁匨inGW鐨勪竴涓洿濂界殑鏂瑰紡錛屼嬌鐢ㄥ厤璐瑰紑婧愮殑Dev-Cpp錛屽叾涓氨鑷甫浜哅inGW錛屾洿濂界殑涓鐐規槸錛屽彲浠ョ敤浠栫殑鍖呯鐞嗗櫒鍒扮綉緇滀笂涓嬭澆闇瑕佺殑紼嬪簭搴擄紝闈炲父鏂逛究錛屼粬榪樻敮鎸丱penGL錛屽鎯崇敤glut搴擄紝浠栦篃鍙互鍦ㄧ綉涓婅嚜鍔ㄦ壘鍒幫紝Qt鐨勫畨瑁呯増涓凡緇忔敮鎸佷簡OpenGL錛屾墍浠ュ浜嶤/C++:
Dev-Cpp + CDT + Eclipse = 鎼炲畾.
 
OpenGL + glut: 鐢―ev-Cpp涓嬭澆glut搴擄紝鐒跺悗鍦‥clipse鐨勫伐紼嬬殑搴撲腑寮曞叆澶栭儴搴擄細
opengl32, glu32, glut32, gdi32, winmm = 鎼炲畾
 
links鏂瑰紡瀹夎鎻掍歡錛?/font>鍦‥clipse鐨勭洰褰曚笅寤轟竴涓猯inks鏂囦歡澶癸紝鍦ㄩ噷闈換鎰忓緩鏂囦歡xxxx.link錛屽湪xxxx.link閲屽啓涓婃彃浠舵墍鍦ㄧ洰褰曪細
path=D:/Software/Eclipse-SDK-3.3M6-win32/CDT-4.0.0-M7-win32.x86錛岃繖閲屽繀欏繪敞鎰忥紝鍏朵腑鐨勬枃浠跺垎闅旂鐢ㄧ殑鏄痩inux鐨勬枃浠跺垎闅旂/錛岃屼笉鏄痺indows鐨勬枃浠跺垎闅旂\錛屽啓閿欎簡鎻掍歡灝辨樉紺轟笉鍑烘潵...寮濮嬬殑鏃跺欑敤\錛屾檿ing錛屾彃浠舵病鏄劇ず鍑烘潵錛岃繕濂戒笉鍌伙紝璇曚簡涓涓?錛屽樋鍢匡紝鍑烘潵浜嗐?/div>
 
Qt: 鍏堣CDT錛岀劧鍚庝笅杞絈t Eclipse Integration瀹夎錛岀洿鎺ユ悶瀹氥傚浜庢柊鍔犲叆鐨?h, .cpp鏂囦歡錛?pro鏂囦歡浼氳嚜鍔ㄦ洿鏂般?/div>
 
瀹屾暣瀹夎欏哄簭錛?/font>
JDK + Eclipse + Dev-Cpp(MinGW...package tool + glut / boost==) + CDT(links瀹夎) + Qt4.3 + Qt Eclipse Integration


]]>C/C++錛欵ffective C++http://www.shnenglu.com/biao/archive/2010/12/17/136782.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:07:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136782.htmlhttp://www.shnenglu.com/biao/comments/136782.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136782.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136782.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136782.html
1.   灝介噺鐢╟onst鍜宨nline錛岃屼笉鐢?define錛屽嵆灝介噺鐢ㄧ紪璇戝櫒錛岃屼笉鐢ㄩ澶勭悊鍣ㄣ?/div>
2.   灝介噺鐢╥ostream錛岃屼笉鐢╯tdio.h銆?/div>
3.   灝介噺鐢╪ew鍜宒elete錛岃屼笉鐢╩alloc鍜宖ree錛屽洜涓簄ew鍜宒elete浼氭墽琛屾瀯閫犲嚱鏁板拰鏋愭瀯鍑芥暟錛岃宮alloc鍜宖ree涓嶄細銆?/div>
4.   灝介噺鍦ㄥ嚱鏁頒腑浣跨敤C++椋庢牸鐨勬敞閲?// 鍑芥暟澶寸敤/* */
5.   new鍜宒elete涓巑alloc鍜宖ree瑕佹垚瀵瑰嚭鐜般?/div>
6.   鏋愭瀯鍑芥暟閲屽鎸囬拡鎴愬憳delete錛宒elete NULL鎸囬拡騫朵笉褰卞搷浠涔堛?/div>
7.   棰勫厛鍑嗗濂藉唴鍦ㄤ笉澶熺殑鎯呭喌錛宼ry{ new..} catch(bad_alloc baex) {}
8.   鍐檕perator new鍜宱perator delete鏃惰閬靛驚甯歌銆?/div>
9.   濡傛灉鍐欎簡operator new錛屽氨瑕佸啓operator delete銆?/div>
10. 涓洪渶瑕佸姩鎬佸垎閰嶅唴瀛樼殑綾繪彁渚涗竴涓鍒舵瀯閫犲嚱鏁板拰璧嬪兼搷浣滆繍綆楃銆?/div>
11. 灝介噺浣跨敤鍒濆鍖栵紝鑰屼笉鍦ㄦ瀯閫犲嚱鏁伴噷璧嬪箋侰C::CC(int v_value) : value(v_value) {}
12. 鍒濆鍖栧垪琛ㄤ腑鎴愬憳鐨勫垪鍑洪『搴忎笌鎴愬憳鐨勫湪綾諱腑鐨勫0鏄庨『搴忕浉鍚屻?/div>
13. 紜畾鍩虹被鏈夎櫄鏋愭瀯鍑芥暟錛屽惁鍒欓噴鏀懼瓙綾繪椂鍙兘鎵ц鍩虹被鐨勬瀽鏋勫嚱鏁幫紝鑰屼笉浼氭墽琛屽瓙綾葷殑铏氭瀯鍑芥暟銆?/div>
14. 璁﹐perator= 榪斿洖*this鐨勫紩鐢紝 (a = b) = c;鍙槸涓轟簡榪欎釜鑳芥紜墽琛岋紝涓嶈繃榪欏彲鏄竴涓緢闃挎牸閲屾媺鐨勭紪紼嬮鏍箋?/div>
15. 鍦╫perator= 涓鎵鏈夋暟鎹垚鍛樿祴鍊箋?/div>
16. 鍦╫perator= 涓鏌ュ鑷繁璧嬪肩殑鎯呭喌銆傚涓嶅鐞嗚繖縐嶆儏鍐碉紝鍦╫perator= 涓厛閲婃斁鎸囬拡瀵硅薄鏁版嵁錛?/div>
     鐒跺悗鍐嶆妸鐩爣鐨勬暟鎹鍒惰繃鏉ワ紝鍥犱負鏄嚜宸辯粰鑷繁澶嶅埗錛屼絾鏁版嵁宸茬粡閲婃斁錛屾墍浠ュ彂鐢熼敊璇?/div>
17. 浜夊彇浣跨被鐨勬帴鍙e畬鏁村茍鏈灝忋?/div>
18. 鍒嗘竻鎴愬憳鍑芥暟錛岄潪鎴愬憳鍑芥暟鍜屽弸鍏冨嚱鏁般?/div>
19. 閬垮厤public鎺ュ彛鍑虹幇鏁版嵁鎴愬憳銆俿et, get.
20. 灝藉彲鑳戒嬌鐢╟onst銆?/div>
21. 灝介噺浼犲紩鐢紝鑰屼笉鏄紶鍊箋俢onst ClassName&銆?/div>
22. 蹇呴』榪斿洖涓涓璞℃椂錛屼笉瑕佽瘯鍥捐繑鍥炰竴涓紩鐢ㄣ傚鍑芥暟涓殑涓存椂鍙橀噺鐨勫紩鐢ㄣ?/div>
23. 鍦ㄥ嚱鏁伴噸杞藉拰璁懼畾鍙傛暟緙虹渷鍊肩殑鍑芥暟涔嬮棿鎱庨噸閫夋嫨銆?/div>
24. 閬垮厤鎸囬拡鍜屾暟瀛楃被鍨嬮噸杞斤細void func(int x)涓巚oid func(string* str)浼犲叆0鏃訛細func(static_cast<string*>(null)銆?/div>
25. 濡傛灉涓嶆兂浣跨敤闅愬紡鐢熸垚鐨勫嚱鏁幫紝灝辨樉紺虹殑紱佺敤瀹冿細private Array& operator=(const Array& ref);
26. 浣跨敤鍚嶅瓧絀洪棿鐨勫ソ澶勶細灝藉彲鑳界殑閬垮厤鍚嶅瓧鍐茬獊寮曞彂鐨勯棶棰樸傚亣濡備竴涓▼搴忎腑鏈夊嚑鐧句釜鍚嶅瓧鍐茬獊錛屽悕瀛楃┖闂磋兘寰堝ソ鐨勮В鍐寵繖涓棶棰樸?/div>
27. 閬垮厤榪斿洖鍐呴儴鏁版嵁鐨勫彞鏌勶細鎸囬拡銆?/div>
28. 閬垮厤榪斿洖private鍜宲rotected鎴愬憳鐨勯潪const寮曠敤鍜屾寚閽堛?/div>
29. 鍗冧竾涓嶈榪斿洖灞閮ㄥ璞$殑寮曠敤錛屼篃涓嶈榪斿洖鍑芥暟鍐呴儴瀹氫箟鐨刵ew鍒濆鍖栫殑鎸囬拡錛屽鏄撳繕鎺塪elete銆?/div>
30. 灝藉彲鑳芥帹榪熷彉閲忕殑瀹氫箟錛岃繖涓湪C涓仛涓嶅埌錛屽畾涔夋棤鐢ㄧ殑鍙橀噺蹇呯劧浼撮殢鏃犵敤鐨勫紑閿銆?/div>
31. 灝嗘枃浠墮棿鐨勭紪璇戜緷璧栨ч檷鑷蟲渶浣庯細鍒嗙鐨勫叧閿湪浜庯細瀵圭被鐨勫0鏄庣殑渚濊禆涓庡綾葷殑瀹氫箟鐨勪緷璧栵細
     灝介噺璁╁ご鏂囦歡涓嶈渚濊禆浜庡彟鐨勬枃浠躲傚浣跨敤ImageLoad.h涓殑Image綾伙紝鍦ㄧ被鐨勫0鏄庝腑涓嶈#include"ImageLoad.h",
     鑰屽彧鏄0鏄庣被class Image; 鍦ㄧ被鐨勫畾涔変腑鎵嶄嬌鐢?include"ImageLoad.h"銆?/div>
     灝介噺涓嶈鍦ㄥご鏂囦歡涓寘鍚叾浠栫殑澶存枃浠躲?/div>
32. 浣跨敤鍑芥暟浣撶幇“鏄竴涓?#8221;鐨勫惈涔夛紝鑰屼笉鏄?#8220;鏈変竴涓?#8221;銆?/div>
33. 鏄庢櫤鐨勪嬌鐢ㄥ緇ф壙錛岃繖涓滆タ涓嶅ソ鐜┿?/div>
34. 緙栬瘧鍣ㄨ兘涓烘垜浠嚜鍔ㄧ敓鎴愮殑鍑芥暟錛?/div>
     鏋勯犲嚱鏁幫紝鏋愭瀯鍑芥暟錛屽鍒舵瀯閫犲嚱鏁幫紝璧嬪艱繍綆楃閲嶈澆錛屼竴瀵瑰彇鍦板潃榪愮畻絎︺?/div>
35. 瀹佸彲緙栬瘧閾炬帴鏃跺嚭閿欙紝涔熶笉鎰胯繍琛屾椂鍑洪敊銆傛瀬灝戞儏鍐典笅浼氫嬌鐢–++鎶涘嚭寮傚父錛氬唴瀛樿楀敖錛?/div>
     C++涓病鏈変笂婧紝涓嬫孩錛岄櫎闆舵鏌ワ紝鏁扮粍瓚婄晫媯鏌ャ?/div>
36. 閲嶈緙栬瘧鍣ㄨ鍛娿?/div>
37. 鐔熸倝鏍囧噯搴擄紝鍦ㄥ悕瀛楃┖闂磗td涓殑銆侰++鐨勪吉鏍囧噯搴擄紝濡俰ostream.h, limits.h銆?/div>
38. 甯稿彉閲忥紝綾繪垚鍛橈紝鐖剁被鏋勯犲嚱鏁拌鏀懼湪鍒濆鍖栧垪琛ㄥ垵濮嬪寲銆?/div>
39. 鎸囬拡瀹氫箟鏃跺垵濮嬪寲涓篘ULL銆?/div>
40. 緇堟瀬瑙e喅澶ф硶錛氳壇濂界殑緙栬瘧涔犳儻鍙緢閬垮厤涓婇潰寰堝鎯呭喌鐨勫彂鐢燂紝濡傛湁涓澶〤++鐨勮娉曞彉寰楀儚Java涓鏍烽檺鍒墮偅涔堝錛?/div>
     灝變笉浼氬嚭鐜拌繖涔堝闂錛屼笉榪囦篃姝e洜涓哄姝わ紝鎵嶅嚭鐜頒簡N澶欳++濂囨帆鎶宸э紝灝卞鑼撮璞嗙殑鑼存湁鍥涚鍐欐硶錛?/div>
     榪欓噷鍙笉姝㈠洓縐嶃?/div>

]]>C/C++錛歀ittle-endian oder Big-endian --> CPUhttp://www.shnenglu.com/biao/archive/2010/12/17/136781.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 10:07:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136781.htmlhttp://www.shnenglu.com/biao/comments/136781.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136781.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136781.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136781.html
鎬庝箞紜畾CPU瀵規搷浣滄暟鐨勫瓨鏀炬柟寮忥紝鐢ㄧ殑鏄疞ittle-endian錛堜粠浣庡瓧鑺傚埌楂樺瓧鑺傦級榪樻槸Big-endian錛?/div>
鍛靛懙錛屽鏋滅煡閬撴庝箞鐢ㄨ仈鍚堜綋鐨勮瘽錛堝啀鍔犱笂浣犳槸涓ぉ鎵嶏細鑳藉嚑鍒嗛挓鍐呮悶鍑鴻繖涓潵鐨勫氨鏄ぉ鎵嶏紝澶╂墠涔熻兘榪欐牱瀹氫箟錛屽嚭棰樼殑浜哄ぇ鑴戞湁闂錛屽樋鍢匡紝榪欓棶棰樺ソ鍍忓緢瀹規槗鍟婏級錛?/div>
union uT{
        short a;
        char b;
}u;
u.a = 0x1234;
 
cout << u.a << endl;
cout << (int)u.b << endl; // 濡傛灉u.b == 0x12,鍒欓噰鐢ㄧ殑鏄疞ittle-endian錛屽洜涓鴻仈鍚堜綋鍗犵敤鍚屼竴涓唴瀛樼┖闂村瓨鏀炬垚鍛樸?/font>
                                   // 鎴戠殑CPU鐢ㄧ殑鏄疊ig-endian錛屼粠楂樺瓧鑺傚埌浣庡瓧鑺傦紝鍥犱負u.b = 52錛孴GA鐨勬枃浠朵篃鏄繖鏍峰瓨鐨勩?/font>
                                   // 鑱斿悎浣撶殑鎴愬憳閮芥槸鎸夊湴鍧欏哄簭浠庝綆鍦板潃鍚戦珮鍦板潃瀛樻斁銆?/font>


]]>C/C++錛氳鍙栨枃浠?/title><link>http://www.shnenglu.com/biao/archive/2010/12/17/136775.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Fri, 17 Dec 2010 09:54:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2010/12/17/136775.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/136775.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2010/12/17/136775.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/136775.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/136775.html</trackback:ping><description><![CDATA[<span style="line-height: 15px; color: rgb(0, 134, 198); font-family: 'BBAlpha Sans', 'Prelude Medium', 'S60 Sans', Tahoma, Verdana, Arial, sans-serif; font-size: 12px; "><div style="line-height: 15px; ">#include <iostream><br style="line-height: 15px; ">#include <cmath><br style="line-height: 15px; ">#include <stdio.h></div><div style="line-height: 15px; "><br style="line-height: 15px; ">using namespace std;</div><div style="line-height: 15px; "> </div><div style="line-height: 15px; ">int main(){<br style="line-height: 15px; ">         FILE* file = NULL;</div><div style="line-height: 15px; "><br style="line-height: 15px; ">         file = fopen("main.cpp", "r");</div><div style="line-height: 15px; ">         if (NULL == file) {</div><div style="line-height: 15px; ">                  cerr << "Cann't open the file." << endl;</div><div style="line-height: 15px; ">                  return 1;</div><div style="line-height: 15px; ">         }<br style="line-height: 15px; "><br style="line-height: 15px; ">         char** line = NULL;<br style="line-height: 15px; ">         line = new char*[60];<br style="line-height: 15px; ">         for (int i = 0; i < 60; i++) {<br style="line-height: 15px; ">                  line[i] = new char[80];<br style="line-height: 15px; ">                 <font color="#ff9900" style="line-height: normal; "> line[i][0] = '\0';</font> <font color="#00ff00" style="line-height: normal; ">// 鍏抽敭灝卞湪榪欓噷錛屽鏋滀笉鎶婃瘡涓覆鐨勭涓涓瓧絎﹁涓?錛屽垯鍦ㄨ緭鍑烘椂錛屽鏋滄簮鏂囦歡鐨勬渶鍚庝竴琛屾槸絀鴻錛?/font></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">                                       // 鍒欐渶鍚庝竴琛屾槸涓や釜瀛楃鐨勪貢鐮?x ?=)錛岃繖鏈夊彲鑳芥槸璺熻鍒版枃浠舵湯鏃剁殑鏂囦歡緇撴潫鏍囧織鏈夊叧銆?br style="line-height: 15px; "></font>         }<br style="line-height: 15px; "> <br style="line-height: 15px; ">         int row = 0;<br style="line-height: 15px; ">         while (!feof(file)) {<br style="line-height: 15px; ">                  fgets(line[row++], 80, file);  // 姣忚鍙栦竴琛屽悗錛岃褰曡鍙栫殑琛屾暟鍔犱竴銆?br style="line-height: 15px; ">         }<br style="line-height: 15px; ">         fclose(file);</div><div style="line-height: 15px; "><br style="line-height: 15px; ">         for (int i = 0; i < row; i++) {<br style="line-height: 15px; ">                  cout << line[i];<br style="line-height: 15px; ">         }</div><div style="line-height: 15px; "><br style="line-height: 15px; ">         return 0; <br style="line-height: 15px; ">}</div></span> <img src ="http://www.shnenglu.com/biao/aggbug/136775.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2010-12-17 17:54 <a href="http://www.shnenglu.com/biao/archive/2010/12/17/136775.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C/C++錛氬悜鍑芥暟浼犻掍簩緇存寚閽堢殑楹葷儲http://www.shnenglu.com/biao/archive/2010/12/17/136773.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 09:52:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136773.htmlhttp://www.shnenglu.com/biao/comments/136773.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136773.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136773.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136773.html
array[3][3],榪欐椂錛宎rray鍗犳湁9涓繛緇殑鍐呭瓨鍗曞厓錛屽湴鍧鏄繛緇殑錛屽鏋滅湡鍙互鐩存帴綆鍗曠殑浼犵粰鎸囧悜鎸囬拡鐨勬寚閽堢殑錛屽垯浜岀淮鎸囬拡鍙栦笅涓涓厓绱犲湴鍧灝辨槸綆鍗曠殑鍔犳硶浜嗭紝浣嗘槸濡傛灉浼犲叆鐨勬寚閽堟槸int** p; p = new int*[3];鍛紵
for (int i = 0; i < 3; i++) {
        *(p + i) = new int[3];
}
榪欐椂浜岀淮鎸囬拡p鐨勫厓绱犲崰鏈夌殑9涓唴瀛樺崟鍏冨嵈涓嶈兘淇濊瘉鏄繛緇殑錛堝彧鑳戒繚璇佹湁姣忚鐨?涓槸榪炵畫鐨勶級錛屽彇涓嬩竴琛屽湴鍧鏃訛紝灝變笉鑳藉涓婇潰鐨勯偅鏍風畝鍗曠殑鐩存帴鐩稿姞浜嗭紙涓婁竴琛屾湯鍏冪礌鐨勫湴鍧鐩存帴鍔?錛夛紝鎵浠ュ緱浼犲叆涓涓寚鍚戞寚閽堢殑鎸囬拡鎵嶈錛屽int* p[3]錛堝瓨鍌ㄧ殑鏄瘡琛岀殑鎸囬拡錛夋垨鑰卛nt** p錛屼負p鍒濆鍖栵紝鍒嗛厤絀洪棿;
鎵浠nt** p 鍜宨nt p[row][column]緇濆涓嶆槸涓鍥炰簨銆?/div>

鍍忎笅闈㈣繖鏍峰彲浠ユ紜繍琛岋細
#include <iostream>
#include <stdio.h>
using namespace std;
void func(int** array, int row, int column) {
         for (int i = 0; i < row; i++) {
                for (int j = 0; j < column; j++) {
                        cout << *(*(array+i) + j) << "\t";
                }
                cout << endl;
        }
}

int main(){
        int array[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        
        int* p[3];
        p[0] = array[0];
        p[1] = array[1];
        p[2] = array[2];
        
        func(p, 3, 3); // 濡傛灉榪欓噷浼犲叆array, array[0], &array[0][0]錛屽垯緙栬瘧涓嶉氳繃
        // 浼犲叆int* q = array[0]; int** p = &q;緙栬瘧閫氳繃錛屼絾榪愯鏃惰涔堥敊閫鍑猴紝瑕佷箞杈撳嚭鐨勭粨鏋滄槸閿欑殑銆?br style="line-height: 15px; ">        
        return 0;
}


]]>C/C++錛氬叓鐨囧悗http://www.shnenglu.com/biao/archive/2010/12/17/136772.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 09:51:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136772.htmlhttp://www.shnenglu.com/biao/comments/136772.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136772.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136772.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136772.html

#include <iostream>
#include <cstdio>
#include <ctime>
#include <cmath>

using namespace std;

void queen(int** array, int row, FILE* fp);
bool isAvailable(int** array, int y, int x);
bool isResult(int** array);

int main(int arg, char** argv) {
        int** array;
        
        // 鍒嗛厤絀洪棿
        array = new int*[8];
        for (int i = 0; i < 8; i++) {
                array[i] = new int[8];
        }
        
        // 鍒濆鍖栫殗鍚庣姸鎬?/font>
        for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                        array[i][j] = 0;
                }
        }
        
        FILE* fp = fopen("data.txt", "w");
        queen(array, 0, fp);
        fclose(fp);
        
        // 閲婃斁絀洪棿
        for (int i = 0; i < 8; i++) {
                delete[] array[i];
        }
        delete array;
        array = NULL;

        return 0;
}

void queen(int** array, int row, FILE* fp) {
        static int size = 1;
        if (row > 7) {
                return;
        }
        for (int j = 0; j < 8; j++) {
                // 濡傛灉鍚堟硶
                if (isAvailable(array, row, j)) {
                        array[row][j] = 1;
                        
                        // 褰撳墠浣嶇疆鍚堟硶錛岃祴鍊煎悗錛岃繘鍏ヤ笅涓琛?br style="line-height: 15px; ">                        queen(array, row + 1, fp);

                        // 濡傛灉閫鍥炴潵鍚庢槸緇撴灉錛屽垯鎵撳嵃鍑烘潵
                        if (isResult(array)) {
                                // 鎶婄粨鏋滃啓鍏ユ枃浠?br style="line-height: 15px; ">                                fputc('\n', fp);
                                fputs("***********************************", fp);
                                fprintf(fp, " %d ", size++);
                                fputs("***********************************", fp);
                                fputc('\n', fp);
                                for (int m = 0; m < 8; m++) {
                                        for (int n = 0; n < 8; n++) {
                                                if (array[m][n] == 1) {
                                                        fputc('#', fp);
                                                        fputc(' ', fp);
                                                        fputc(' ', fp);
                                                } else {
                                                        fputc('O', fp);
                                                        fputc(' ', fp);
                                                        fputc(' ', fp);
                                                }
                                        }
                                        fputc('\n', fp); 
                                }

                        }
                        array[row][j] = 0;

                }
        }
}

bool isAvailable(int** array, int row, int column) { // 絎瑀ow琛岋紝column鍒?br style="line-height: 15px; ">        int i, j;

        // 媯鏌ow琛?/font>
        for (i = 0; i < 8; i++) {
                if (array[row][i] != 0) {
                        return false;
                }
        }

        // 媯columnx鍒?/font>
        for (j = 0; j < 8; j++) {
                if (array[j][column] != 0) {
                        return false;
                }
        }

        // 媯鏌ュ瑙掑悜宸︿笂
        i = row;
        j = column;
        while (i >= 0 && j >= 0) {
                if (array[i][j] != 0) {
                        return false;
                }
                i--;
                j--;
        }

        // 媯鏌ュ瑙掑悜鍙充笂
        i = row;
        j = column;
        while (i >= 0 && j < 8) {
                if (array[i][j] != 0) {
                        return false;
                }
                i--;
                j++;
        }

        // 媯鏌ュ瑙掑悜宸︿笅
        i = row;
        j = column;
        while (i < 8 && j >= 0) {
                if (array[i][j] != 0) {
                        return false;
                }
                i++;
                j--;
        }

        // 媯鏌ュ瑙掑悜鍙充笅
        i = row;
        j = column;
        while (i < 8 && j < 8) {
                if (array[i][j] != 0) {
                        return false;
                }
                i++;
                j++;
        }

        return true;
}

bool isResult(int** array) {
        int size = 0; // 鐨囧悗涓暟

        // 緇熻鐨囧悗涓暟
        for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                        if (array[i][j] != 0) {
                                size++;
                        }
                }
        }

        // 娌℃湁錛樹釜鐨囧悗錛岃鏄庝笉鏄粨鏋?/font>

       // 鏈?涓殗鍚?鍥犱負姣忎釜鐨囧悗鐨勬斁緗兘鏄湪鍚堟硶浣嶇疆, 鎵浠ュ彧闇瑕佺畝鍗曠殑璁$畻鐨囧悗涓暟灝辯煡閬撴槸涓嶆槸緇撴灉.
        if (size != 8) {
                return false;
        }

        return true;
}



]]>
C/C++錛欳涓殢鏈鴻鍐欐枃浠?/title><link>http://www.shnenglu.com/biao/archive/2010/12/17/136766.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Fri, 17 Dec 2010 09:48:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2010/12/17/136766.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/136766.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2010/12/17/136766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/136766.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/136766.html</trackback:ping><description><![CDATA[<span style="line-height: 15px; color: rgb(0, 134, 198); font-family: 'BBAlpha Sans', 'Prelude Medium', 'S60 Sans', Tahoma, Verdana, Arial, sans-serif; font-size: 12px; "><div style="line-height: 15px; ">#include <iostream><br style="line-height: 15px; ">#include <cstdio></div><div style="line-height: 15px; "> </div><div style="line-height: 15px; ">using namespace std;</div><div style="line-height: 15px; "> </div><div style="line-height: 15px; ">int main(int argc, char** argv) {<br style="line-height: 15px; ">        FILE* fp = NULL;<br style="line-height: 15px; ">        fp = fopen("data.txt", "w");</div><div style="line-height: 15px; ">        fputs("gooooooooogle", fp);<br style="line-height: 15px; ">        fclose(fp);<br style="line-height: 15px; ">        fp = NULL;</div><div style="line-height: 15px; ">        fp = fopen("data.txt", "r+");</div><div style="line-height: 15px; ">        <font color="#00ff00" style="line-height: normal; ">// 璇誨彇淇敼鍓嶇殑鍐呭<br style="line-height: 15px; "></font>        char str[50];<br style="line-height: 15px; ">        cout << "------------淇敼鍓嶇殑鍐呭---------" << endl;<br style="line-height: 15px; ">        cout << fgets(str, 50, fp) << endl;</div><div style="line-height: 15px; "> </div><div style="line-height: 15px; ">        <font color="#00ff00" style="line-height: normal; ">// 闅忔満淇敼鏂囦歡.<br style="line-height: 15px; "></font>        rewind(fp);<br style="line-height: 15px; ">        fseek(fp, 3L, SEEK_SET);<br style="line-height: 15px; ">        //cout << ftell(fp) << endl;<br style="line-height: 15px; ">        fputc('A', fp);<br style="line-height: 15px; ">        fputc('B', fp);<br style="line-height: 15px; ">        fseek(fp, 1L, SEEK_CUR);<br style="line-height: 15px; ">        fputc('C', fp);</div><div style="line-height: 15px; ">        <font color="#00ff00" style="line-height: normal; ">// 璇誨嚭淇敼鍚庣殑鍐呭<br style="line-height: 15px; "></font>        rewind(fp);<br style="line-height: 15px; ">        cout << "------------淇敼鍚庣殑鍐呭---------" << endl;<br style="line-height: 15px; ">        cout << fgets(str, 50, fp) << endl;</div><div style="line-height: 15px; ">        fclose(fp);<br style="line-height: 15px; ">        return 0;<br style="line-height: 15px; ">}</div><div style="line-height: 15px; "> </div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">/**<br style="line-height: 15px; "> * 涓嶈兘鐢╢open(fileName, "w+"); // 濡傛灉鏂囦歡涓嶅瓨鍦?鍒涘緩鏂囦歡,濡傛灉瀛樺湪,鍒欐竻絀?鐒跺悗璇誨啓<br style="line-height: 15px; "> * fopen(fileName, "a+"); // 鍙兘鍐欏埌鏂囦歡灝?浣嗗彲浠ヨ鍙?<br style="line-height: 15px; "> * fopen(fileName, "r+"); // 鍙互璇誨啓, 濡傛灉鏂囦歡涓嶅瓨鍦? 鍒欏彂鐢熼敊璇?鍙互瀹炵幇闅忔満璇誨啓.<br style="line-height: 15px; "> */</font></div></span> <img src ="http://www.shnenglu.com/biao/aggbug/136766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2010-12-17 17:48 <a href="http://www.shnenglu.com/biao/archive/2010/12/17/136766.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C/C++錛歄verload + Templatehttp://www.shnenglu.com/biao/archive/2010/12/17/136757.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 09:30:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136757.htmlhttp://www.shnenglu.com/biao/comments/136757.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136757.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136757.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136757.html
鍑芥暟閲嶈澆錛?/font>
鍑芥暟鍚嶅瓧鐩稿悓錛屾渶灝戣搗鐮佹槸鍙傛暟鐨勭被鍨嬩笉涓鏍鳳紝鍙傛暟涓暟涓嶄竴鏍烽偅鏇村ソ浜嗭紝浣嗘槸涓嶈兘鍙槸榪斿洖綾誨瀷涓嶄竴鏍楓?/font>
void func(int n) {...};
void func(float n) {...};
涓璧瘋皟鐢細
func(10);
func(20.001);
榪欐椂緙栬瘧涓嶉氳繃錛屾彁紺洪噸杞藉嚱鏁扮殑璋冪敤涓嶆竻妤氾紝鍥犱負絎簩涓彲鑳戒細鎶奻loat寮哄埗杞崲涓篿nt錛屾墍浠ュ繀欏繪槑紜殑寮哄埗鎸囧畾涓篺loat鎵嶈錛屼笅闈㈢殑璋冪敤緙栬瘧閫氳繃錛?/font>
func(10);
func((float)20.001); 鎴栬?func(20.00f);
 
閲嶈澆鍑芥暟閫氳繃絳懼悕(signature)榪涜璇嗗埆錛岀鍚嶆槸鍑芥暟鍚嶅拰鍙傛暟綾誨瀷鐨勭粍鍚堛?/font>
緙栬瘧鍣ㄧ敤鍑芥暟鍙備釜鏁板拰綾誨瀷緙栫爜姣忎釜鍑芥暟鏍囪瘑絎?鎴栧悕瀛楁敼緙?錛屼互淇濊瘉綾誨瀷瀹夊叏榪炴帴銆傚Borland C++涓紝姣忎釜
鏀圭紪鍚嶇敤 @鍔犱笂鍑芥暟鍚?/font>
鏀圭紪鍙傛暟浠?$q 寮澶?/font>
zc 琛ㄧず char, pf 涓?float*, pd 涓?double*, i 涓?int, pi, f, d,
濡?void nothing(int a, float b, char c, double *d); 鐨勬敼緙栧悕涓?/font>
@nothing$qifzcpd
 
閲嶈澆鍑芥暟閫氬父鐢ㄤ簬涓嶅悓綾誨瀷鐢ㄤ笉鍚岀▼搴忛昏緫榪涜綾諱技鐨勬搷浣溿?/font>
濡傛灉姣忕鏁版嵁綾誨瀷鐨勭▼搴忛昏緫鍜屾搷浣滅浉鍚岋紝閭d箞浣跨敤鍑芥暟妯℃澘浼氭洿濂戒竴浜涖?/font>
template <class T>
T max(T a, T b, T c) {
        T max;
        max= a > b? a : b;
        max = max > c? max : c;
        return max;
}
 


]]>
C/C++錛欰rray and Pointerhttp://www.shnenglu.com/biao/archive/2010/12/17/136756.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Fri, 17 Dec 2010 09:30:00 GMThttp://www.shnenglu.com/biao/archive/2010/12/17/136756.htmlhttp://www.shnenglu.com/biao/comments/136756.htmlhttp://www.shnenglu.com/biao/archive/2010/12/17/136756.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/136756.htmlhttp://www.shnenglu.com/biao/services/trackbacks/136756.html
鏁扮粍鍜屾寚閽堣繖涓滆タ鏈夋椂榪樻槸姣旇緝楹葷儲錛?/font>
鎸囬拡鏄緢鍗遍櫓鐨勶紝浣嗗悓鏃朵篃鏄潪甯稿己澶х殑錛?/font>灝卞涓涓珮鎵嬫嬁AWP鍜屼竴涓彍楦熸嬁AWP涓鏍鳳紝涓涓槸鏈鎭愭栫殑欖旈錛屽彟涓涓嵈鏄铏愮殑瀵硅薄銆?/font>
const int *p 鍜?int const *p 鎸囩殑鏄暟緇勭殑鍐呭涓嶈兘鏀瑰彉銆?/font>
int * const p 鎸囩殑鏄寚閽堝悕涓嶈兘鏀瑰彉銆傝皝鍦?const 鍚庨潰錛岃皝灝辨槸涓嶅彉鐨勩?/font>
 
浜岀淮鏁扮粍鍔ㄦ佸垎閰嶏細
int **p;
int row = 5;
int column = 10;
p = new int*[row];
for (int i=0; i<row; i++) {
        p[i] = new int[column];
}
 
鎸囬拡鍗蟲槸鍦板潃(0xf0765fea)錛屾槸鏃犵鍙鋒暣鏁幫紝鍗犵敤鍥涗釜瀛楄妭錛岋紦錛掍綅銆?/font>鎬庝箞鍒ゆ柇涓涓寚閽堟墍鎸囧悜鐨勭被鍨嬶紵
鍘繪帀涓涓*銆鍜屽彉閲忓悕鍚庢墍鐣欎笅鐨勯儴鍒嗗氨鏄寚閽堟墍鎸囧悜鐨勭被鍨嬨?/font>
濡?int *p; 鍘繪帀涓涓?* 鍜屽彉閲忓悕 p 鍚庡氨鍙湁 int 浜嗭紝鎵浠?p 鎸囧悜 int 鐨勬暣褰㈡暟銆?/font>
float **p; 鍒?p 鎸囧悜鐨勭被鍨嬫槸 float *錛屽嵆 float 綾誨瀷鐨勬寚閽堬紝鎴?float 綾誨瀷鐨勫湴鍧錛屼篃鍗蟲暟緇勩?/font>
閭d箞鍦ㄧ粰 p 鍒嗛厤鍐呭瓨鏃訛紝p = new float*[23]錛屽嵆鎸囧悜涓浜?/font>
鍦跡鎴栵跡錛嬶紜涓湁涓涓緢濂界殑鍦版柟鏄紝鍗充嬌浣犲畾涔夌殑鍙橀噺鏄寚閽堬紝浣嗗彲涓庣敤璁塊棶鏁扮粍涓嬫爣鐨勬柟娉曟潵璁塊棶鎸囬拡鎵鎸囧悜鐨勬暟鎹紱int **p;   *(*(p+i) + j) 絳夊悓浜?p[i][j]錛屼嬌鐢ㄦ暟緇勪笅鏍囨潵璁塊棶鏇寸洿瑙傘?/font>
 
浣跨敤鍙橀噺鏉ュ0鏄庢暟緇勭殑闀垮害錛屼嬌紼嬪簭鏇村叿鏈夊仴澹? int length = 10; int array[length].
緇欏畾涓涓簩緇存暟緇勫拰涓涓綅緗暟loc錛屾庝箞紜畾榪欎釜鏁板搴旀暟緇勪腑鐨勯偅涓涓綅緗紵
array[loc / column][loc % column]
 
褰撳畾涔変竴涓暟緇勬椂錛屼絾娌℃湁鍒濆鍖栵紝榪欐椂鏁扮粍鐨勫唴瀹規槸榪樻槸鍘熸潵鍐呭瓨涓殑鍊箋?/font>
 
void * 鐨勪嬌鐢?/font>
鍙互鎶婁換浣曠被鍨嬬殑鎸囬拡鐩存帴浼犵粰 void* 鐨勫彉閲忋?/font>
浣嗘槸鍙嶈繃鏉ワ紝鍗翠笉鑳界洿鎺ユ妸 void* 浼犵粰鍏朵粬綾誨瀷鎸囬拡錛屽繀欏繪槑紜殑榪涜寮哄埗綾誨瀷杞崲
int *pi;
void * pv = pi; // Ok
float *pf = (float*)pv; // Ok
double *pd = pv; // Error
 
char *str = (char*)malloc(sizeof(char) * number);
malloc鍒嗛厤涓孌靛唴瀛橈紝榪斿洖榪欐鍐呭瓨鐨勯鍦板潃錛屽叾鍊間負 void *錛岃繖鏍鳳紝涓嶇浠涔堢被鍨嬬殑鎸囬拡閮藉彲浠ョ敤榪欎釜鍑芥暟鏉ヨ繘琛屽唴瀛樺垎閰嶏紝void * 瀹炵幇浜嗙浉褰撲簬 C++ 涓殑鍑芥暟妯℃澘鐨勫姛鑳斤紝瀹炵幇浜嗗湪錛d腑鐨勫鎬併傚悇縐嶇被鍨嬭鏄庣錛屽氨鏄負浜嗚鏄庢瘡嬈¤繘琛屽瓨鍙栫殑鏃跺欐搷浣滃灝戝瓧鑺傘?/font>
 
鏁扮粍鍚嶆槸榪欎釜鏁扮粍鐨勯鍦板潃錛屼笌浠栫殑絎竴涓厓绱犵殑鍦板潃鏄寚鍚戝悓涓涓湴鍧錛屼絾鏁扮粍鍗存槸涓涓父閲忥紝鍙兘榪涜鍙沖艱綆楋紝鏄笉鍙敼鍙樼殑銆傛寚閽堝彉閲忎篃鏄寚鍚戝湴鍧錛屼絾鎸囬拡鍙橀噺鏄彲浠ユ敼鍙樼殑錛屽彲浠ヨ繘琛屽彸鍊艱綆楋紝涔熷彲浠ュ乏鍊艱綆椼?/font>
 
瀛楃鏁扮粍鐨勭粨鏉熺鍙鋒槸'\0'錛屽叾鏁村瀷鍊兼槸 0錛屽嵆 NULL
铏界劧榪欐牱錛屼絾鍦∣penGL涓紝濡傚湪 glGenTextures 鐨勮皟鐢ㄤ腑錛岀粡甯哥敤鐨勬槸絎竴涓厓绱犵殑鍦板潃錛岃屼笉鏄敤鏁扮粍鍚嶃?/font>
 
鐢ㄦ暟緇勫疄鐜版姌鍗婃煡鎵撅細
鍦ㄦ渶鍧忕殑鎯呭喌涓嬶紝1024涓厓绱犲彧闇瑕佽繘琛?0鏌ユ壘錛屼絾鏌ユ壘鍓嶈鍏堟帓搴?/font>
榪斿洖瑕佹煡鎵劇殑鏁板湪鏁扮粍鐨勪笅鏍囷紝褰撲笉鍦ㄦ暟緇勪腑鏄紝榪斿洖 -1錛屽洜涓烘暟緇勪笅鏍囨槸浠庯紣寮濮嬬殑銆?/font>
int binarySearch(const int *p, const int g, int low, int height) {
         int mid;
 
         while (low <= height) {
                 mid = (low + height) / 2;
                 if (g < p[mid]) {
                          height = mid - 1;
                 } else if (g > p[mid]) {
                          low = mid + 1;
                 } else {
                          return mid;
                 }
          }
 
          return -1;
}
 
蹇熸帓搴忥細
void quickSort(int *p, int low, int height) {
          if (low >= height) {
                  return;
          }
 
          const int l = low;
          const int h = height;
          int ref = p[(low + height)/2];
          int temp = 0;
 
          // 濡傛灉娌℃湁絳変簬榪欎釜鏉′歡錛岄偅涔堝銆3, 2, 1鏃訛紝灝變細閫犳垚涓嬩竴嬈℃帓搴忎負1,2 ; 2, 3錛屽鍑烘潵涓涓?2
          while (low <= height) {
                    // 鎵懼埌澶т簬絳変簬 ref 鐨勬暟錛岃繖閲屽緢閲嶈錛屽鏋滅敤 <= 鐨勮瘽錛屽嵆鎵懼埌姣?ref 澶х殑鏁幫紝
銆                 // 鍙兘浼氶犳垚鏁扮粍瓚婄晫
                    while (p[low] < ref) { 
                              low++;
                    }  
                    while (p[height] > ref) {
                              height--;
                    }
  
                    // 榪欎釜鏉′歡鏄繀欏葷殑錛屽惁鍒欎笉鑳芥紜帓搴忥紝銆l錛戯紝錛擄紝錛旓紝錛掞紝錛掞紝錛擄紝h錛? 3涓簉ef
                    // 絎竴嬈℃帓搴忓悗錛?, 3, l4, 2, h2, 3, 5
                    // 絎簩嬈℃帓搴忓悗錛?, 3, 2, lh2, 4, 3, 5錛岃繖鏃惰繕鍙互榪涜涓嬩竴嬈℃帓搴?/font>
                    // 絎笁嬈℃帓搴忥紝h浠嶅湪2澶勶紝浣唋瑕佹壘澶т簬絳変簬浠栫殑鏁幫紝鍗?, 3, 2, h2, l4, 3, 5
                    // 濡傛灉娌℃湁榪欎釜鏉′歡錛岄偅涔堝氨瑕佽繘琛屼氦鎹紝1, 3, h2, 4, 2, l3, 5錛屾湁閿欒鍙戠敓
                    if (low <= height) {
                              temp = p[low];
                              p[low] = p[height];
                              p[height] = temp;
                              low++;
                              height--;
                    }
  
          }
 
          quickSort(p, low, h);
          quickSort(p, l, height);
          // 絎竴嬈″帇鍏?low, height)
銆銆銆  // 浠庢爤涓彇鍑轟竴瀵?low, height)榪涜姣忎釜鐗囨鐨勬帓搴?/font>
          // 姣忔帓瀹屼竴閬嶅悗錛屽嵆涓婇潰鐨剋hile鎵ц瀹屼竴嬈★紝鍘嬪叆(low,h)鍜?l,height)
銆銆銆  // 鍒╃敤鏍堟秷闄ら掑綊
 
          return;
}
 
鎺掑簭涓鑸綋鍏冪礌涓暟澶т簬涓夊崄涓椂鍒╃敤蹇熸帓搴忕殑閫熷害姣旇緝蹇紝褰撳厓绱犱釜鏁板皬浜庝笁鍗佷釜鏃訛紝鍒╃敤閫夋嫨鎺掑簭姣旇緝濂斤紝鎵浠ヤ竴鑸兘鏄夋嫨鎺掑簭鍜屽揩閫熸帓搴忕粨鍚堣搗鏉ヤ嬌鐢ㄣ?/font>


]]>
C/C++錛氬嚱鏁版寚閽?/title><link>http://www.shnenglu.com/biao/archive/2010/12/17/136754.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Fri, 17 Dec 2010 09:27:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2010/12/17/136754.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/136754.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2010/12/17/136754.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/136754.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/136754.html</trackback:ping><description><![CDATA[<span style="line-height: 15px; color: rgb(0, 134, 198); font-family: 'BBAlpha Sans', 'Prelude Medium', 'S60 Sans', Tahoma, Verdana, Arial, sans-serif; font-size: 12px; "><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">鍑芥暟鎸囬拡錛?/font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">鍑芥暟鍚嶅氨鏄嚱鏁版搷浣滀唬鐮佸湪鍐呭瓨涓殑璧峰鍦板潃錛屽氨鍍忔暟緇勫悕鏄暟緇勫湪鍐呭瓨涓殑璧峰鍦板潃銆?/font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">鎵浠ヤ嬌鐢ㄥ嚱鏁版寚閽堟椂錛岀洿鎺ヤ紶鍏ュ嚱鏁板悕灝變粈涔堜簡銆傚嚱鏁版寚閽堜篃鏄跡涓疄鐜板鎬佺殑涓縐嶆柟娉曘?/font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; "></font> </div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">int x2(int x) { return x * x;}</font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">int x3(int x) {return x * x * x;}</font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">void func(int (*pf)(int), int x) { cout << pf(x) << endl;}</font></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">== void func(int (*pf)(int), int x) { cout << (*pf)(x) << endl;}</font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">func(x2, 4); // 16</font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; ">func(x3, 4); // 64</font></div><div style="line-height: 15px; "><font color="#dba04f" style="line-height: normal; "></font> </div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; "><font color="#ff9900" style="line-height: normal; ">void *func(int* (*pf)(int*, const int**, float, char * const), double *);</font> // 鍛靛懙錛屽ご鏅曞惂</font></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; "></font> </div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; "><font color="#ff9900" style="line-height: normal; ">void (*pf[10])(int);</font> // 琛ㄧずpf鏄?0涓嚱鏁版寚閽堢殑鏁扮粍</font></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">鍑芥暟鎸囬拡鐨勪竴涓敤娉曟槸寤虹珛涓涓彍鍗曢┍鍔ㄧ▼搴忥細</font></div><div style="line-height: 15px; "><font color="#00ff00" style="line-height: normal; ">鐢ㄦ埛浠庤彍鍗曚腑閫夋嫨涓涓夐」錛屾瘡涓夐」鐢變笉鍚岀殑鍑芥暟鎻愪緵鏈嶅姟錛屾瘡涓嚱鏁扮殑鎸囬拡瀛樻斁鍦ㄥ嚱鏁版寚閽堟暟緇勪腑銆傜敤鎴烽夐」浣滀負鏁扮粍涓嬫爣錛屾暟緇勪腑鐨勬寚閽堢敤浜庤皟鐢ㄨ繖涓嚱鏁般?/font></div><div style="line-height: 15px; "><font color="#ff9900" style="line-height: normal; ">void 錛?pf[3])(int) = {func1, func2, func3};</font></div></span><img src ="http://www.shnenglu.com/biao/aggbug/136754.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2010-12-17 17:27 <a href="http://www.shnenglu.com/biao/archive/2010/12/17/136754.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C錛氬湪緇堢閲岃緭鍑烘鐜勪綑鐜?/title><link>http://www.shnenglu.com/biao/archive/2010/11/07/132831.html</link><dc:creator>閫涘鐨勮湕鐗?/dc:creator><author>閫涘鐨勮湕鐗?/author><pubDate>Sat, 06 Nov 2010 22:40:00 GMT</pubDate><guid>http://www.shnenglu.com/biao/archive/2010/11/07/132831.html</guid><wfw:comment>http://www.shnenglu.com/biao/comments/132831.html</wfw:comment><comments>http://www.shnenglu.com/biao/archive/2010/11/07/132831.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/biao/comments/commentRss/132831.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/biao/services/trackbacks/132831.html</trackback:ping><description><![CDATA[ 鍥犱負鍦ㄧ粓绔噷杈撳嚭錛屽彧鑳藉線鍓嶏紝寰涓嬭緭鍑虹殑鐗規э紝鎵浠ヨ縐葷敤瀵圭О鎬ф潵瀹炵幇杈撳嚭姝g巹錛屼綑鐜勫浘妗堛? <div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; color: #5000ff"><span style="color: #a1006a">#include</span><span style="color: #000000"> </span><stdio.h></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; color: #a1006a">#include<span style="color: #000000"> </span><span style="color: #5000ff"><math.h></span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco"><span style="color: #a1006a">int</span> main() {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    <span style="color: #a1006a">double</span> y;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    <span style="color: #a1006a">int</span> x, f, i;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">    </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; color: #2f9570"><span style="color: #000000">    </span>/* 杈撳嚭姝g巹, 鍗曡皟鍖洪棿 x: [-pi/2, pi/2], y: [-1, 1] */</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; color: #2f9570"><span style="color: #000000">    </span>/* 瑕佸垎鎴愪袱涓儴鍒嗘潵璁$畻杈撳嚭 */</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    <span style="color: #a1006a">for</span> (y = 1; y > 0; y -= 0.1) {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        x = asin(y) * 10;</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">        </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        <span style="color: #a1006a">for</span> (i = 1; i < x; ++i) printf(<span style="color: #5000ff">" "</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        printf(<span style="color: #5000ff">"*"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        <span style="color: #a1006a">for</span> (; i < 32 - x; ++i) printf(<span style="color: #5000ff">" "</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        printf(<span style="color: #5000ff">"*\n"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">    </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    <span style="color: #a1006a">for</span> (y = 0; y >= -1; y -= 0.1) {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        x = asin(y) * 10; <span style="color: #2f9570">/* x鏄礋鍊?*/</span></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">        </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        <span style="color: #a1006a">for</span> (i = 1; i < 34 - x; ++i) printf(<span style="color: #5000ff">" "</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        printf(<span style="color: #5000ff">"*"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        <span style="color: #a1006a">for</span> (; i < 66 + x; ++i) printf(<span style="color: #5000ff">" "</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        printf(<span style="color: #5000ff">"*\n"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">    </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    printf(<span style="color: #5000ff">"\n\n"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">    </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; color: #2f9570"><span style="color: #000000">    </span>/* 杈撳嚭浣欑巹, 鍗曡皟鍖洪棿 x: [0, pi], y: [1, -1] */</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    <span style="color: #a1006a">for</span> (y = 1; y >= -1; y -= 0.1) {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        x = (<span style="color: #a1006a">int</span>)(acos(y) * 10);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco; min-height: 19.0px">        </p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        <span style="color: #a1006a">for</span> (i = 0; i <= 64; ++i) {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">            <span style="color: #a1006a">if</span> (i == x || i == 64 - x) {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">                printf(<span style="color: #5000ff">"*"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">            } <span style="color: #a1006a">else</span> {</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">                printf(<span style="color: #5000ff">" "</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">            }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">        printf(<span style="color: #5000ff">"\n"</span>);</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">    }</p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Monaco">}</p></div><div><br></div><img src ="http://www.shnenglu.com/biao/aggbug/132831.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/biao/" target="_blank">閫涘鐨勮湕鐗?/a> 2010-11-07 06:40 <a href="http://www.shnenglu.com/biao/archive/2010/11/07/132831.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C++錛歋now Leopard閲屽畨瑁匫penCV 2.1 (鎶樼(浜虹殑涓滆タ)http://www.shnenglu.com/biao/archive/2010/10/30/131849.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Sat, 30 Oct 2010 08:05:00 GMThttp://www.shnenglu.com/biao/archive/2010/10/30/131849.htmlhttp://www.shnenglu.com/biao/comments/131849.htmlhttp://www.shnenglu.com/biao/archive/2010/10/30/131849.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/131849.htmlhttp://www.shnenglu.com/biao/services/trackbacks/131849.htmlhttp://sites.google.com/site/michaelsafyan/setup-guide/mac-os-x-10-6-snow-leopard
1. 瀹夎MacPort錛?nbsp;涓嬭澆Download MacPorts鐨刣mg錛岀洿鎺ュ畨瑁?/strong>
2. Install PkgConfig using MacPorts: sudo port install pkgconfig
3. Install CMake using MacPorts:: sudo port install cmake
4. Configure PKG_CONFIG_PATH: 
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig
export PKG_CONFIG_PATH=~/.local/lib/pkgconfig:/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH
echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> ~/.profile
鍦ㄥ畨瑁卌make鏃惰娉ㄦ剰錛屽洜涓哄湪Snow Leopard 10.6.4涓洜涓篔DK宸茬粡鍗囩駭榪囦簡錛屽湪sudo port install cmake鏃朵細鎻愮ず閿欒錛岃В鍐蟲柟娉曪細

I am in a different position with respect to this fix. I had installed cmake 2.8.2_3 before the Apple Java update. After the Apple Java update, the cmake upgrade from 2.8.2_3 to 2.8.2_4 failed saying that I needed to install Java from Apple, which was already installed. As far as I can tell, the Apple update to Java 1.6.0_22 did not properly update the header path. In the updated version the header path leads to a dead end. I was able to fix this by doing the following.

1) Create directory

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Headers

2) Copy entire contents of directory

/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers

to directory

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Headers

After this fix the upgrade to cmake 2.8.2_4 worked. However, if the macports cmake could be made to look for the Java headers in /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers this would resolve an existing problem.

From: https://trac.macports.org/ticket/26934


5. 鏈緇堝ぇ鎴忔潵浜嗭紝瀹夎OpenCV: http://sunny.in.th/2010/04/27/installing-opencv-21-on-snow-leopard.html

Installing OpenCV 2.1 on Snow Leopard has become quite easy at least easier than 2.0. Version 2.1 can now be compiled as 64-bit library.

Before version 2.1 OpenCV used Carbon which is the old GUI interface for Mac OS. Carbon supports only 32-bit and has been deprecated by Apple. The new GUI interface for Mac OS is Cocoa. With Snow Leopard being a 64-bit kernel it would be nice if we could compile OpenCV as a 64-bit library and not not 32-bit just because of Carbon. Thanks to the OpenCV team they have added Cocoa support in version 2.1.

To install OpenCV check out the code from the svn repository and compile it.

$ svn co https://code.ros.org/svn/opencv/trunk/opencv
$ cd opencv
$ mkdir build 
$ cd build 
$ cmake .. 

Configure the make by

$ ccmake .

If you want you can build the samples as well.

ccmake

Press c to configure, followed by g to generate. Next build and install OpenCV by

$ make -j8
$ sudo make install

That’s it!!! Simple right.

If you want to use Python with OpenCV there’s a little more that needs to be done. By default OpenCV copies the shared object file required by the Python interface to /usr/local/lib/python2.6/site-packages/cv.so which is not under Python path. Add the following line to your .bashrc or .bash_profile

PYTHONPATH=/usr/local/lib/python2.6/site-packages/cv.so:$PYTHONPATH

Trying running some C samples which are in /usr/local/share/opencv/samples/c/. The Python samples at/usr/local/share/opencv/samples/python/ doesn’t work since they are based on the old SWIG-Python interface. Try running the sample Python code which is in the opencv directory that was checked out from subversion. It’s insidesamples/python.

 



]]>
C++錛歍ype Castinghttp://www.shnenglu.com/biao/archive/2010/10/08/128986.html閫涘鐨勮湕鐗?/dc:creator>閫涘鐨勮湕鐗?/author>Thu, 07 Oct 2010 21:25:00 GMThttp://www.shnenglu.com/biao/archive/2010/10/08/128986.htmlhttp://www.shnenglu.com/biao/comments/128986.htmlhttp://www.shnenglu.com/biao/archive/2010/10/08/128986.html#Feedback0http://www.shnenglu.com/biao/comments/commentRss/128986.htmlhttp://www.shnenglu.com/biao/services/trackbacks/128986.htmlConverting an expression of a given type into another type is known as type-casting. We have already seen some ways to type cast:

Implicit conversion

Implicit conversions do not require any operator. They are automatically performed when a value is copied to a compatible type. For example:

short a=2000;
int b;
b=a;

Here, the value of a has been promoted from short to int and we have not had to specify any type-casting operator. This is known as a standard conversion. Standard conversions affect fundamental data types, and allow conversions such as the conversions between numerical types (short to intint to floatdouble to int...), to or from bool, and some pointer conversions. Some of these conversions may imply a loss of precision, which the compiler can signal with a warning. This can be avoided with an explicit conversion.

Implicit conversions also include constructor or operator conversions, which affect classes that include specific constructors or operator functions to perform conversions. For example:

class A {};
class B { public: B (A a) {} };

A a;
B b=a;

Here, a implicit conversion happened between objects of class A and class B, because B has a constructor that takes an object of class A as parameter. Therefore implicit conversions from A to B are allowed.

Explicit conversion

C++ is a strong-typed language. Many conversions, specially those that imply a different interpretation of the value, require an explicit conversion. We have already seen two notations for explicit type conversion: functional and c-like casting:

short a=2000;
int b;
b = (int) a;    // c-like cast notation
b = int (a);    // functional notation

The functionality of these explicit conversion operators is enough for most needs with fundamental data types. However, these operators can be applied indiscriminately on classes and pointers to classes, which can lead to code that while being syntactically correct can cause runtime errors. For example, the following code is syntactically correct:

// class type-casting
#include <iostream>
using namespace std;

class CDummy {
    float i,j;
};

class CAddition {
	int x,y;
  public:
	CAddition (int a, int b) { x=a; y=b; }
	int result() { return x+y;}
};

int main () {
  CDummy d;
  CAddition * padd;
  padd = (CAddition*) &d;
  cout << padd->result();
  return 0;
}
 

The program declares a pointer to CAddition, but then it assigns to it a reference to an object of another incompatible type using explicit type-casting:

padd = (CAddition*) &d;

Traditional explicit type-casting allows to convert any pointer into any other pointer type, independently of the types they point to. The subsequent call to member result will produce either a run-time error or a unexpected result.

In order to control these types of conversions between classes, we have four specific casting operators: dynamic_castreinterpret_caststatic_cast and const_cast. Their format is to follow the new type enclosed between angle-brackets (<>) and immediately after, the expression to be converted between parentheses.

dynamic_cast <new_type> (expression)
reinterpret_cast <new_type> (expression)
static_cast <new_type> (expression)
const_cast <new_type> (expression)

The traditional type-casting equivalents to these expressions would be:

(new_type) expression
new_type (expression)

but each one with its own special characteristics:

dynamic_cast: 杞崲瀛愮被鐨勬寚閽?鎴栧紩鐢?涓虹埗綾葷殑鎸囬拡(鎴栧紩鐢?

dynamic_cast can be used only with pointers and references to objects. Its purpose is to ensure that the result of the type conversion is a valid complete object of the requested class.

Therefore, dynamic_cast is always successful when we cast a class to one of its base classes:

class CBase { };
class CDerived: public CBase { };

CBase b; CBase* pb;
CDerived d; CDerived* pd;

pb = dynamic_cast<CBase*>(&d);     // ok: derived-to-base
pd = dynamic_cast<CDerived*>(&b);  // wrong: base-to-derived

The second conversion in this piece of code would produce a compilation error since base-to-derived conversions are not allowed with dynamic_cast unless the base class is polymorphic.

When a class is polymorphic, dynamic_cast performs a special checking during runtime to ensure that the expression yields a valid complete object of the requested class:

// dynamic_cast
#include <iostream>
#include <exception>
using namespace std;

class CBase { virtual void dummy() {} };
class CDerived: public CBase { int a; };

int main () {
  try {
    CBase * pba = new CDerived;
    CBase * pbb = new CBase;
    CDerived * pd;

    pd = dynamic_cast<CDerived*>(pba);
    if (pd==0) cout << "Null pointer on first type-cast" << endl;

    pd = dynamic_cast<CDerived*>(pbb);
    if (pd==0) cout << "Null pointer on second type-cast" << endl;

  } catch (exception& e) {cout << "Exception: " << e.what();}
  return 0;
}
Null pointer on second type-cast

Compatibility note: dynamic_cast requires the Run-Time Type Information (RTTI) to keep track of dynamic types. Some compilers support this feature as an option which is disabled by default. This must be enabled for runtime type checking using dynamic_cast to work properly.

The code tries to perform two dynamic casts from pointer objects of type CBase* (pba and pbb) to a pointer object of type CDerived*, but only the first one is successful. Notice their respective initializations:

CBase * pba = new CDerived;
CBase * pbb = new CBase;

Even though both are pointers of type CBase*pba points to an object of type CDerived, while pbb points to an object of type CBase. Thus, when their respective type-castings are performed using dynamic_castpba is pointing to a full object of class CDerived, whereas pbb is pointing to an object of class CBase, which is an incomplete object of class CDerived.

When dynamic_cast cannot cast a pointer because it is not a complete object of the required class -as in the second conversion in the previous example- it returns a null pointer to indicate the failure. If dynamic_cast is used to convert to a reference type and the conversion is not possible, an exception of type bad_cast is thrown instead.

dynamic_cast can also cast null pointers even between pointers to unrelated classes, and can also cast pointers of any type to void pointers (void*).

static_cast: 鎸囬拡鐨勮漿鎹? 1. 瀛愮被鍜岀埗綾諱箣闂存寚閽堜簰鐩歌漿鎹?涓嶈繘琛屽畨鍏ㄦ鏌?. 闈炴寚閽堢殑杞崲: 2. 鏍囧噯闅愬紡杞崲(濡俰nt->float, double->int). 3. 鐢ㄦ埛瀹氫箟杞崲(鏋勯犲嚱鏁拌漿鎹紝杞崲鍑芥暟)

static_cast can perform conversions between pointers to related classes, not only from the derived class to its base, but also from a base class to its derived. This ensures that at least the classes are compatible if the proper object is converted, but no safety check is performed during runtime to check if the object being converted is in fact a full object of the destination type. Therefore, it is up to the programmer to ensure that the conversion is safe. On the other side, the overhead of the type-safety checks of dynamic_cast is avoided.

class CBase {};
class CDerived: public CBase {};
CBase * a = new CBase;
CDerived * b = static_cast<CDerived*>(a);

This would be valid, although b would point to an incomplete object of the class and could lead to runtime errors if dereferenced.

static_cast can also be used to perform any other non-pointer conversion that could also be performed implicitly, like for example standard conversion between fundamental types:

double d=3.14159265;
int i = static_cast<int>(d); 

Or any conversion between classes with explicit constructors or operator functions as described in "implicit conversions" above.

reinterpret_cast: 1. 浠諱綍鎸囬拡涔嬮棿鐨勭浉浜掕漿鎹紝鍗充嬌榪欎簺綾誨瀷涔嬮棿娌℃湁浠諱綍鍏崇郴. 2. 鎸囬拡鍜屾暣鏁扮被鍨嬬殑鐩鎬簰杞崲(鎸囬拡->int鏃跺湪Mac涓婁細鎶ラ敊: loses precision).

reinterpret_cast converts any pointer type to any other pointer type, even of unrelated classes. The operation result is a simple binary copy of the value from one pointer to the other. All pointer conversions are allowed: neither the content pointed nor the pointer type itself is checked.

It can also cast pointers to or from integer types. The format in which this integer value represents a pointer is platform-specific. The only guarantee is that a pointer cast to an integer type large enough to fully contain it, is granted to be able to be cast back to a valid pointer.

The conversions that can be performed by reinterpret_cast but not by static_cast have no specific uses in C++ are low-level operations, whose interpretation results in code which is generally system-specific, and thus non-portable. For example:

class A {};
class B {};
A * a = new A;
B * b = reinterpret_cast<B*>(a);

This is valid C++ code, although it does not make much sense, since now we have a pointer that points to an object of an incompatible class, and thus dereferencing it is unsafe.

const_cast: 杞崲瀵硅薄(primitive綾誨瀷鐨勪笉鍙互: int, float, double...)錛屾寚閽堬紝寮曠敤鐨刢onst灞炴э紝鏈夊垯鍘繪帀錛屾病鏈夊垯鍔犱笂

This type of casting manipulates the constness of an object, either to be set or to be removed. For example, in order to pass a const argument to a function that expects a non-constant parameter:

// const_cast
#include <iostream>
using namespace std;

void print (char * str)
{
  cout << str << endl;
}

int main () {
  const char * c = "sample text";
  print ( const_cast<char *> (c) );
  return 0;
}
sample text

typeid

typeid allows to check the type of an expression:

typeid (expression)

This operator returns a reference to a constant object of type type_info that is defined in the standard header file <typeinfo>. This returned value can be compared with another one using operators == and != or can serve to obtain a null-terminated character sequence representing the data type or class name by using its name() member.

// typeid
#include <iostream>
#include <typeinfo>
using namespace std;

int main () {
  int * a,b;
  a=0; b=0;
  if (typeid(a) != typeid(b))
  {
    cout << "a and b are of different types:\n";
    cout << "a is: " << typeid(a).name() << '\n';
    cout << "b is: " << typeid(b).name() << '\n';
  }
  return 0;
}
a and b are of different types:
a is: int *
b is: int  

When typeid is applied to classes typeid uses the RTTI to keep track of the type of dynamic objects. When typeid is applied to an expression whose type is a polymorphic class, the result is the type of the most derived complete object:

// typeid, polymorphic class
#include <iostream>
#include <typeinfo>
#include <exception>
using namespace std;

class CBase { virtual void f(){} };
class CDerived : public CBase {};

int main () {
  try {
    CBase* a = new CBase;
    CBase* b = new CDerived;
    cout << "a is: " << typeid(a).name() << '\n';
    cout << "b is: " << typeid(b).name() << '\n';
    cout << "*a is: " << typeid(*a).name() << '\n';
    cout << "*b is: " << typeid(*b).name() << '\n';
  } catch (exception& e) { cout << "Exception: " << e.what() << endl; }
  return 0;
}
a is: class CBase *
b is: class CBase *
*a is: class CBase
*b is: class CDerived

Notice how the type that typeid considers for pointers is the pointer type itself (both a and b are of type class CBase *). However, when typeid is applied to objects (like *a and *btypeid yields their dynamic type (i.e. the type of their most derived complete object: 鐪熷疄鐨勭被鍨嬶紝鍗充嬌瀛愮被瀵硅薄浣跨敤鐨勬槸鐖剁被鐨勬寚閽堬紝浣嗚繑鍥炵殑瀛愮被鐨勪俊鎭?.

If the type typeid evaluates is a pointer preceded by the dereference operator (*), and this pointer has a null value, typeid throws a bad_typeid exception.



]]>
99国内精品久久久久久久 | 久久免费看黄a级毛片| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久本道久久综合伊人| www亚洲欲色成人久久精品| 精品久久无码中文字幕| 久久精品国产99久久久香蕉| 一个色综合久久| 久久99精品久久久久久久久久| 国产精品热久久毛片| 少妇被又大又粗又爽毛片久久黑人 | 久久久久久久免费视频| 久久人人添人人爽添人人片牛牛 | 精品久久久久久无码人妻热| 色天使久久综合网天天| 久久狠狠色狠狠色综合| 思思久久99热只有频精品66| 香蕉久久夜色精品国产小说| 无码人妻久久一区二区三区免费| 国产高潮国产高潮久久久91| 久久水蜜桃亚洲av无码精品麻豆 | 精品久久久久香蕉网| 一级做a爰片久久毛片免费陪| 久久福利青草精品资源站免费| 亚洲乱码中文字幕久久孕妇黑人| 久久久久亚洲AV无码专区网站 | 精品水蜜桃久久久久久久| 午夜精品久久久久久毛片| 午夜精品久久久久| 无夜精品久久久久久| 国产福利电影一区二区三区久久老子无码午夜伦不| 久久久久久国产精品无码下载| 日批日出水久久亚洲精品tv| 久久人人超碰精品CAOPOREN| 99热成人精品免费久久| 亚洲国产天堂久久综合网站| 国产精品午夜久久| 国产精品成人久久久久三级午夜电影| 国产亚洲欧美成人久久片| 2020久久精品国产免费| 久久99精品国产99久久6男男|