Abstract一個很簡單的題目,來看看C和C++要如何實現。IntroductionC語言1 /* 2 (C) OOMusou 2008 http://oomusou.cnblogs.com3 4 Filename : array_minus_1.c5 Compiler : Visual C++ 8.06 Description : Demo how to minus 1 in each element of array7 Release : 03/26/2008 1.08
結構體可以看做是一種自訂的資料類型,它還有一個很重要的特性,就是結構體可以相互嵌套使用,但也是有條件的,結構體可以包含結構體指標,但絕對不能在結構體中包含結構體變數。struct test { char name[10]; float socre; test *next; };//這樣是正確的!struct test { char name[10]; float socre; test next;
在多線程或單線程任務中,讓線程帶傳入參數一直是個麻煩的問題,通常有種方法就是以類,對像的變數來傳參數,這種方法理解上很簡單不過在某些場合使用很麻煩,這裡就不介紹了,我們主要介紹一種.NET2.0中新增加的帶參數運行線程的方法,樣本程式如下:ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadMethod); Thread myThread = new Thread(ParStart);
利用設計模式可以使我們的代碼更靈活,更容易擴充,更容易維護。各種物件導向的程式設計語言都提供了基本相同的機制:比如類、繼承、派生、多態等等。但是又有各自的特色,C# 中的反射機制便是一個很重要的工具,好好地利用就可以在實際中發揮很大的作用。我們來看一個例子:我的程式中有需要一系列的對象,比如apple,orange…, 要想利用他們,我們就必須在程式中根據使用者要求,然後一個個調用 new
http://www.cppreference.com/operator_precedence.html PrecedenceOperatorDescriptionExampleAssociativity1()[]->.::++--Grouping operatorArray accessMember access from a pointerMember access from an objectScoping
C++ 11標準新增加了Lambda運算式,以後小函數可以直接內嵌Lambda運算式搞定了。例如排序,我們以前要這麼寫:#include <iostream>#include <cstdlib>#include <algorithm>bool compare( const int & a, const int & b ){ return a < b;}using namespace std;int main ( ){
Abstractprintf()只能顯示10、8、16進位的值,卻無法顯示2進位的值,但有時候我們會希望能直接顯示2進位數字。Introduction使用環境:Visual C++ 8.0 / Visual Studio 2005Method 1:這是從C Primer Plus 5/e改寫的,使用bit運算來將10進位轉2進位,相當漂亮的寫法。decimal2binary.c / CCode highlighting produced by Actipro CodeHighlighter
Abstract同學問我的小問題,還蠻有趣的,就順便寫寫看。Introduction使用環境:Visual C++ 9.0 / Visual Studio 2008get_c_class_ip_host_id.c / CCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 /* 2 (C) OOMusou 2008