Time of Update: 2018-12-03
C++在類的建構函式中,可以兩種方式初始化成員資料(data member)。 1,在建構函式的實現中,初始類的成員資料。諸如:class point{private:int x,y;public:point(int m=0,int n=0){ x=m; y=n;}int GetX(){ return x;}int GetY(){ return y;}};2,還可以定義初始化成員列表(Initializer list)來初始化成員資料(data member)。改寫建構函式如下:
Time of Update: 2018-12-03
本地C代碼中建立Java對象建立Java域的對象就是建立Java類的執行個體,再調用Java類的構造方法。以Bitmap的構建為例,Bitmap中並沒有Java對象建立的代碼及外部能訪問的構造方法,所以它的執行個體化必然是在JNI的c中實現的。BitmapFactory.java中提供了得到Bitmap的方法,時序簡化為:BitmapFactory.java ->BitmapFactory.cpp -> GraphicsJNI::createBitmap()
Time of Update: 2018-12-03
一、基類:class ICMDStatic {public: ICMDStatic(); virtual ~ICMDStatic(); virtual UINT TestFunc()=0;};二、子類1:class CCMD502 : public ICMDStatic{public: CCMD502(); virtual ~CCMD502(); virtual UINT TestFunc(){return 1;};};三、子類2:class CCMD503 : public
Time of Update: 2018-12-03
#include <string.h>int main(int argc, const char * argv[]){ unsigned char* c=NULL; c = (unsigned char*)malloc(15); unsigned char d[5]={1,2,3,4,5}; unsigned char e[5]={11,22,33,44,55}; memcpy(c, d, sizeof(d)); memcpy(c+5, e,
Time of Update: 2018-12-03
#include<iostream>#include<string>using namespace std;int main(){ string s1="hello"; string s2=" world"; string s3=s1+s2;//兩個string相加,是允許的 string s4="hello"+" word";//只有字串字面值相加,是不允許的 cout<<s3<<endl;//正確的 cout<<s4<<
Time of Update: 2018-12-03
#include<iostream>#include<string>#include<vector>using namespace std;template<typename T>inline int compare(const T &a,const T &b){ if(a>b) return 1; if(a<b) return -1; if(a==b) return 0;}int main(){ int a=10
Time of Update: 2018-12-03
設計模式的重要性就不用多說了。各種設計模式在實際項目中用的是比比皆是。一:簡單原廠模式和原廠模式懂得一點UML,一看這幅類圖,就知道原廠模式是用來幹嘛的,說白了,就是提供一個抽象的基類介面,使得使用者不用記住具體的要成成的新的類的名字。下面 看一段代碼:#include<iostream>#include<string>#include<vector>using namespace std;class
Time of Update: 2018-12-03
分別建兩個工程。。把cpp拷貝進去運行就可以了。。。server端: #include <WINSOCK2.H>#include <stdio.h>#pragma comment(lib,"ws2_32.lib")void main(){ //建立通訊端 WORD myVersionRequest; WSADATA wsaData; myVersionRequest=MAKEWORD(1,1); int
Time of Update: 2018-12-03
下面就是excel批量上傳資料到資料庫一:UI層1.前台代碼:<a>上傳檔案(Excel):<asp:FileUpload ID="FileUpload1" runat="server" Width="237px" /></a> <a> <asp:Button ID="btnUp" runat="server" Text="匯入資料庫" Width="75px"
Time of Update: 2018-12-03
1.變數聲名C# :int x;String s;String s1, s2;Object obj;Object obj = new Object();public String name;VB文法Dim x As IntegerDim s As StringDim s1, s2 As StringDim obj 'Implicitly ObjectDim obj As New Object()Public name As String 2語句C#:Response.Write("123456"
Time of Update: 2018-12-03
C# 2.0引入了很多語言擴充,最重要的就是泛型(Generics)、匿名方法(Anonymous Methods)、迭代器(Iterators)和不完全類型(Partial Types)。• 泛型允許類、結構、介面、委託和方法通過它們所存貯和操作的資料的類型來參數化。泛型是很有用的,因為它提供了更為強大的編譯期間類型檢查,需要更少的資料類型之間的顯式轉換,並且減少了對裝箱操作的需要和運行時的類型檢查。•
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;namespace 多線程{ class 同步模式 { public static void Main() { //對於不同步版本的順序調用,沒什麼值得說明的 //Demo d = new Demo() ;
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Text;namespace 字串{ class Program { static void Main( string[] args ) { //字串頻繁分配記憶體示範(不推薦) //以下代碼將字串全總向後移一個值,原來的字串將會被替換成新加密後的.
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Text;namespace IDisposeDemo{ /** * C#中不建議使用解構函式來釋放資源,因為 * 1 解構函式的執行時間不確定,不會像c++一樣在引用失效時立即調用.. * 2 使用解構函式會造成效能的浪費,解構函式會使GC兩次才能真正釋放資源, * 如果沒有解構函式,在失去引用時,GC執行時,堆中就會被清除,但是有解構
Time of Update: 2018-12-03
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading ;namespace 多線程{ class 簡單語句原子化 { public static void Main() { //Interlocked類提供了一些簡單的同步運算功能,比如++ --等。 //
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 泛型{ class 泛型介面 { public static void Main() { PersonManager man = new PersonManager(); Person per = new Person();
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Text;namespace IDisposeDemo{ class 回收資源樣本 { public static void Main( string[] args ) { using ( Person p = new Student() ) { }
Time of Update: 2018-12-03
自從看了ScottGu的幾篇文章後就有想讓C#3.0的一些新特性在我的部落格上也留下曆史地一頁。但是由於環境不允許好久都沒有用上.NET 3.0,今天終於忍不住地要動一動鍵盤滿足一下自己的慾望,因為我自己的電腦上安裝了.NET 3.0 Framework SDK。在這裡我總結一下前輩們的研究成果,也為進一步鞏固自己的知識以便今後的開發,同時也希望能夠給大家帶來一點回憶。 下面我們來看一看我們在指令碼中常用的變數的聲明的"var"關鍵字,美其名曰隱式聲明變數,所申明變數的類型由第一個對其賦值(
Time of Update: 2018-12-03
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 泛型{ // 泛型特性:1預設值