Time of Update: 2015-06-05
標籤:淺拷貝#include <iostream>#include <string.h>using namespace std;class String{public:String(const char *str = " "){m_data = new char[strlen(str) + 1];strcpy(m_data, str);count++;}String(const String &s){m_data =
Time of Update: 2015-06-05
標籤:逗號運算子主要用於串連運算式,例如: int a = 9;int b = 10;a = a+1 , b = 3*4;* 用逗號運算子串連起來的運算式稱為逗號運算式,它的一般形式為:運算式1, 運算式2, … …, 運算式n逗號運算式的運算過程是:從左至右的順序,先計算運算式1,接著計算運算式2,...,最後計算運算式n* 逗號運算子也是一種運算子,因此它也有運算結果。整個逗號運算式的值是最後一個運算式的值int a = 2;int b = 0;int c;c = (++a, a *= 2
Time of Update: 2015-06-05
標籤:智能指標// vc下的智能指標,重點在於擁有權的轉移#include <iostream>using namespace std;template<class Type>class Autoptr{public:Autoptr(int *p = NULL) :ptr(p), owns(ptr != NULL){}Autoptr(const Autoptr<Type> &t) :ptr(t.release()),
Time of Update: 2015-06-05
標籤://---------------------------------------------------------------------------#include <vcl.h>#pragma hdrstop#include "Unit1.h"#include <vector>#include <algorithm>using namespace std;//--------------------------------------------
Time of Update: 2015-06-05
標籤:概述: 近期中國股市起起伏伏,當然了起伏就用商機,小明發現商機後果斷想入市,買入了中國證券,他想在電腦client上,網頁上,手機上,iPad上都能夠查看到該證券的即時行情,這樣的情況下我們應該怎麼設計我們的軟體呢?我們能夠這樣:小明的全部client上都訂閱中國證券這個股票,僅僅要股票一有變化,全部的client都會被通知到而且被自己主動更新。 這就是我們的觀察者模式,
Time of Update: 2015-06-05
標籤:基於 http://www.cnblogs.com/diegodu/p/4555018.html operator new的知識基礎上 介紹這個章節的內容 對於一般直接 new 與delete 效能較差,可以自己管理寫記憶體的申請與釋放。其實一般的operator new 和operator delete 直接調用 malloc 和 free的。版本0:class Rational{public: Rational(int a=0, int b =1 ):
Time of Update: 2015-06-05
標籤:系統類別型排序;NSArray *goodsNames [email protected][@"computer",@"iphone",@"ipad"];NSArray *sortedArray=[goodsNames sortedArrayUsingSelector:@selector(compare:)];自訂排序Person *p1=[[Person alloc]initWithName:@"tom" andAge:12 andCard:nil];Person *p2=[[
Time of Update: 2015-06-05
標籤:在C++類成員中引用,常量,靜態變數,靜態函數等,它們被分配在記憶體的那個地方,有哪些特性。1.常量和引用必須重載建構函式進行初始化,否則就會編譯失敗, new
Time of Update: 2015-06-05
標籤:template類派學習處理模板化基類裡的名稱本節作者編寫的意圖在我看來可以總結成一句話,就是“如何定義並使用關於模板類的派生過程,如何處理派生過程出現的編譯不通過問題”。下面我們看一段說明性的代碼:#include<iostream>using namespace std;class object1{public: void get(){ cout << "object1"; } void out(){ cout << "out1"; }}
Time of Update: 2015-06-05
標籤:智能指標 c++ 類模板 避免異常 //【C++】智能指標auto_ptr的簡單實現#include <iostream>using namespace std;template <class _Ty>class auto_ptr{public: auto_ptr(_Ty *_P = 0) :_Owns(_Ptr != 0),
Time of Update: 2015-06-05
標籤:異常 安全 深賦值 深拷貝 // 深拷貝,異常安全的深賦值#include <iostream>#include <string.h>using namespace std;class String{public:String(const char *str = " "){m_data = new
Time of Update: 2015-06-05
標籤:新的關鍵字autoC++11中引入auto第一種作用是為了自動類型推導。auto的自動類型推導,用於從初始設定式中推斷出變數的資料類型。通過auto的自動類型推導,可以大大簡化我們的編程工作。auto實際上實在編譯時間對變數進行了類型推導,所以不會對程式的運行效率造成不良影響。另外,似乎auto並不會影響編譯速度,因為編譯時間本來也要右側推導然後判斷與左側是否匹配。如果沒有auto關鍵字 寫個迭代器要寫很長長,這也算是節省了我們的腦細胞吧。auto a; //
Time of Update: 2015-06-05
標籤:http://www.younfor.com/cpp-new-placement-new-operator-new.html http://www.cnblogs.com/luxiaoxun/archive/2012/08/10/2631812.html http://kelvinh.github.io/blog/2014/04/19/research-on-operator-new-and-delete/ new operator
Time of Update: 2015-06-05
標籤:字母:數字單個數字\d非數字\D字元邊界 \b任一字元 .字元點 \.或[abc]:匹配 a 或b 或c 都能匹配重複多次 c{2} 匹配兩個c重複多次(範圍) b{2,3} 匹配重複2到3次b重複多次(0-多次) b* 匹配 0個到多個b重複多次(1-多次) b+ 匹配 1個到多個b匹配單個 b? 匹配要麼有b 要麼沒b匹配空白 \s(小s) 匹配所有不是空白的地方 \S(大S)開頭 ^結尾 $任意長度*綜合測試:
Time of Update: 2015-06-05
標籤:/// <summary> /// 將json轉換為DataTable /// </summary> /// <param name="strJson">得到的json</param> /// <returns></returns> public static DataTable JsonToDataTable(string strJson)
Time of Update: 2015-06-05
標籤:Microsoft.Office.Interop.Excel.Application excel=new Microsoft.Office.Interop.Excel.Application();Microsoft.Office.Interop.Excel.Workbooks workbooks=excel.Workbooks;Microsoft.Office.Interop.Excel.Workbook
Time of Update: 2015-06-05
標籤:c# 自訂 implicit explicit 轉換 explicit 和 implicit 屬於轉換運算子,如用這兩者可以讓我們自訂的類型支援相互交換explicti 表示顯式轉換,如從 A -> B 必須進行強制類型轉換(B = (B)A)implicit 表示隱式轉換,如從 B -> A
Time of Update: 2015-06-05
標籤:當C#遇到這種提示: which has a higher version than referenced assembly,說明有兩個或多個工程引用的dll的版本有出現不一樣,如:A工程引用log4Net的版本為2.0;B工程引用log4Net的版本為1.8; A工程和B工程最終在同一個啟動工程中同時用到,就會出現類似問題。 解決辦法:將它們改為引用同一個版本的dll。 C# 遇到 which has a higher version than
Time of Update: 2015-06-05
標籤:1、FileStream只處理原始位元組,不處理字元,使用StreamRead和StreamWrite處理字元。 1)使用FileStream處理字串時,須經過中間類的轉換: byte[] byData = new byte[200]; char[] charData = new Char[200]; //Byte2Char Decoder d = Encoding.UTF8.GetDecoder()
Time of Update: 2015-06-05
標籤:windows7 windows 設定檔 使用者名稱 電腦 使用者移轉 對於IT員工來說最經常最多的工作就是重新安裝系統,但是各種IT從業者,不得不面對一個問題,那就是重新安裝系統前的備份問題,有沒有可能直接把使用者檔案遷移到非C盤外的其他盤符呢? 答案是肯定的。