Time of Update: 2018-12-05
以下精彩的回帖來自C++討論群組:Why besides the type system? I haven't read every part of the discussion, but let me try to highlight some points of semantics here.我還沒讀完這次討論中的所有部分,不過請讓我突出強調一下這次討論中的某些觀點。 Let's assume we have a fully dynamic, strongly-typed language,
Time of Update: 2018-12-05
MSDN例子// MemoryBlock.h#pragma once#include <iostream>#include <algorithm>class MemoryBlock{public:// Simple constructor that initializes the resource.explicit MemoryBlock(size_t length): _length(length), _data(new int[length]){std::cout &
Time of Update: 2018-12-05
以下精彩的回帖來自C++討論群組:future of the C++ Unlike other popular languages before it, like COBOL, or after it, like Perl, C++ says,與流行語言的前輩(如COBOL)和後輩(如Perl)不同,C++語言作出如下聲明: "Ok, we all know that most computers follow a von Neumann architecture more or less,
Time of Update: 2018-12-05
代碼如下:#region "工具條按鈕" //拉框放大 private void toolStripButton_Zoomin_Click(object sender, EventArgs e) { currentoperation = "拉框放大"; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerZoomIn;
Time of Update: 2018-12-05
Visual Studio 2010 的 C++ 編譯器(VC10)支援六項C++0x新特性:auto、右值引用、static_assert、nullptr、lambda運算式以及decltype。與同樣在標準出台之前誕生的VC6相比較,在與標準的契合度這一點上VC10顯然有了巨大的進步,但遺憾的是,在功能增強同時編譯器自身也不可避免地引入了不少bug,尤其是關於lambda運算式,下面略舉幾例。 1.int main(){struct X {};auto a = [](){return X(
Time of Update: 2018-12-05
1.在C++ 程式中調用被C 編譯器編譯後的函數,為什麼要加extern “C”?答:首先,extern是C/C++語言中表明函數和全域變數作用範圍的關鍵字,該關鍵字告訴編譯器,其聲明的函數和變數可以在本模組或其它模組中使用。通常,在模組的標頭檔中對本模組提供給其它模組引用的函數和全域變數以關鍵字extern聲明。extern "C"是串連申明(linkage declaration),被extern
Time of Update: 2018-12-05
一個簡單的模型。server發送命令給client,client接收命令並處理。//client.c#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <netdb.h>#include <sys/types.h>#include <netinet/in.h>#include
Time of Update: 2018-12-05
目前我瞭解到使用Mono做指令碼的只有Unity和SecondLife, SpringEngine也有個擴充實現.當然, 最成熟的還是Unity於是下載了一個看看它的指令碼是怎麼應用的它的編輯器介面很簡潔, 實際操作了一下才發現所有的功能其本上都是由inspector面板完成所有的GameObject都是由Component所組成, 如Mesh/Physics/Audio/Script等等指令碼都是從MonoBehaviour派生的一個實現, 在其中實現上層定義的各種介面,
Time of Update: 2018-12-05
純C++代碼在大多數情況下並不適合直接加入到C++/CLI項目裡.相同的純C++代碼,在C++/CLI項目中,效率要比原生代碼低得多。各種inline,SSE指令,自動SIMD指令都會失效。如果這個時候,自作聰明的在純C++代碼上關閉Managed
Time of Update: 2018-12-05
研究Flash嵌入遊戲中的可行性.......渲染問題已解決事件響應已解決下面是C++與Flash AS的互動, 以MFC為例:1. 建立一個MFC Dialog程式2. 添加一個Flash控制項 3. 把Flash控制項添加一個變數 4. 在OnInitDialog()中添載入.swf檔案// CCppFlashDlg 訊息處理常式 BOOL CCppFlashDlg::OnInitDialog(){ CDialog::OnInitDialog(); //
Time of Update: 2018-12-05
物件導向的思想:封裝,繼承,多態性.1.範圍運算子"::"範圍:變數在程式中的起作用範圍簡單分為:全域範圍,局部範圍,語句範圍範圍優先順序:範圍越小優先順序越高範圍運算子:"::"如果希望在局部變數的範圍內使用同名的全域變數,可以在該變數前加上"::","::"稱為範圍運算子.//範圍#include <iostream>usingnamespace std;int avar=10;//全域變數avarint main(){int
Time of Update: 2018-12-05
this指標我並不陌生,學過java的都知道,this在java中也經常出現。今天我專門研究了一下C++中的this指標。http://www.cnblogs.com/hnrainll/archive/2011/05/20/2051939.htmlthis指標指向的就是調用該方法的對象,對this的解引用*this就是調用該方法的對象。this指標的含義及其用法: 1. this指標是一個隱含於每一個成員函數中的特殊指標。它指向正在被該成員函數操作的那個對象。2.
Time of Update: 2018-12-05
看《effective
Time of Update: 2018-12-05
剛開始我一直感覺建造者模式不太好懂,也許是我笨了點緣故,勤能補拙嘛,所以只能多看多想了大話設計模式裡面那個對於建造者模式我講解,個人感覺不太好理解,我是看了很多遍也沒體會到那樣設計的精髓,後來在另一本設計模式上才稍微領悟到了點, 在這裡我想到一個比較形象的例子:比如我某天去吃蘭州拉麵,他們有不同的套餐,套餐裡包含的種類是一樣的,都有一碗拉麵,一份泡菜,一杯飲料。但是不同的套餐裡這3樣又都不是全部一樣的,也許分量和品質有差別。此時我們就可以用建造者模式。這裡我沒有合適的UML圖,大致說一下模型:客
Time of Update: 2018-12-05
char Dec2HexChar(short int n) { if ( 0 <= n && n <= 9 ) { return char( short('0') + n ); } else if ( 10 <= n && n <= 15 ) { return char( short('A') + n - 10 ); } else { return char(0);
Time of Update: 2018-12-05
從前用native API實現過程式開機自動運行,前幾天剛好要用到,就用c#重寫了,基本原理都是一樣的。RegistryKey KeyCon=Registry.LocalMachine.OpenSubKey("Software//Microsoft//Windows//CurrentVersion//Run",true);string MyKey= "Terminal"; if((string)KeyCon.GetValue(MyKey,"no") ==
Time of Update: 2018-12-05
以下三個函數定義為標頭檔memory中,下面是其可能的實際代碼。代碼來源於《The C++ Standard Library》namespace std{template<class ForwIter,class T>void uninitialized_fill(ForwIter beg,ForwIter end, const T& value){typedef typename iterator_traits<ForwIter>::value_type VT;
Time of Update: 2018-12-05
當然不是自己解碼的,不過有神人這麼做:http://hi.baidu.com/avengine/blog/item/9b7147a94c78c4fc1e17a2f7.html還有這個http://sourceforge.net/projects/php-ms-demangle/是抄的 wine 的。搞這個是為瞭解決 gcc typeinfo::name 返回的不是原始名字的問題。gcc 輸出:St6vectorISsSaISsEEstd::vector<std::string, std::
Time of Update: 2018-12-05
#define _CRT_SECURE_NO_DEPRECATE#include <string> // 使用 string 類時須包含這個檔案#include <iostream>using namespace std;int main(){string str1;// 輸入與輸出cout << "輸入字串 str1" << endl;cin >> str1; getchar();cout << str1
Time of Update: 2018-12-05
#include <iostream>int main(){// 基本思路:// 無符號數與有符號數比較時,有符號數會被轉換成無符號數unsigned int a = 0;// 無符號數// int a = 1;// 有符號數int b = -1;// b是符號數,-1轉換成無符號數後是最大的無符號數4294967295if(a < 0)std::cout << "有符號數" << std::endl;else{std::cout << b