Time of Update: 2018-12-05
1. 以下三條輸出語句分別輸出什嗎?[C易]char str1[] = "abc";char str2[] = "abc";const char str3[] = "abc"; const char str4[] = "abc"; const char* str5 = "abc";const char* str6 = "abc";cout << boolalpha << ( str1==str2 ) << endl; //
Time of Update: 2018-12-05
#include "stdafx.h"#include <complex>using namespace std;class Base{public: virtual void f(int); virtual void f(double); virtual void g(int i = 10);};void Base::f(int){ cout << "Base::f(int)" << endl;}void Base::f(double){ cout <
Time of Update: 2018-12-05
//蛙蛙推薦:示範索引指標的用法(C#)// 本示範測試連續自然數中的質數的個數,質數就是除了1和它本身能整除為,不能被別人整除了.// 不好意思,小時候數學學的不好,關於怎麼判斷質數的演算法我沒有理解透澈呢,不過這不影響你瞭解索引指標的建立和使用,大家誰懂,麻煩指點一下哦// 注釋比較多,如果去除所有注釋,代碼還是很緊湊的,沒辦法,現在就得做一些很基礎的練習.using System; //匯入命名空間class BitArray //定義一個類BitArray{ int[]
Time of Update: 2018-12-05
C#定義了一個類System.Windows.Forms.Clipboard來簡化剪下板操作,這個類有一個靜態方法,主要有:Clear
Time of Update: 2018-12-05
1:字元數組換為字串見代碼#include <iostream>#include <string>using namespace std;int main(){char a[10]="aaaabbbba";string s(&a[0],&a[strlen(a)]);cout<<s<<endl;system("pause");}2:把字串轉換為字元數組見代碼:#include <iostream>#include <
Time of Update: 2018-12-05
/lib/direct/Util.c//字串歸整處理,去掉前後無用的字元void direct_trim( char **s ){ int i; int len = strlen( *s );//從後往前檢查,去除空格和多餘的非法字元,直到倒數第一個有效字元 for (i = len-1; i >= 0; i--) if ((*s)[i] <= ' ') (*s)[i] =
Time of Update: 2018-12-05
最近在開發中用到了函數指標,於是想整理了一下有關函數指標的概念。O(∩_∩)O~ 首先 函數指標是指向一組同類型的函數的指標;而類成員函數我們也可以相似的認為,它是指向同類中同一群組類型的成員函數的指標,當然這裡的成員函數更準確的講應該是指非靜態成員函數。前者是直接指向函數地址的,而後者我們從字面上也可以知道 它肯定是跟類和對象有著關係的。 函數指標執行個體:typedef int (*p)(int,int);//定義一個接受兩個int型且返回int型變數的函數指標類型int
Time of Update: 2018-12-05
http://www.cnblogs.com/kiss007/archive/2012/06/05/2537407.html%x 整數的參數會被轉成一無符號的十六進位數字,並以小寫abcdef表示 %X 整數的參數會被轉成一無符號的十六進位數字,並以大寫ABCDEF表示浮點型數 %d 整數的參數會被轉成一有符號的十進位數字 %u 整數的參數會被轉成一無符號的十進位數字 %o 整數的參數會被轉成一無符號的八位元字 %x
Time of Update: 2018-12-05
1.操作符重載對大部分符號成立,一下幾種不能重載:" . ", " .* ", " ::", " ?: ", " sizeof "。2.操作符重載分為 成員函數重載 和 全域函數重載,(“ = ”,“ ( ) ”,“ [ ] ",” ->
Time of Update: 2018-12-05
C++中的struct對C中的struct進行了擴充,它已經不再只是一個包含不同資料類型的資料結構了,它已經擷取了太多的功能。struct能包含成員函數嗎? 能!struct能繼承嗎? 能!!struct能實現多態嗎? 能!!!有很多人應該已經知道這樣一個事實,但總有些不知道的人,看到這些會感到很驚訝。是的,當我第一次注意到這個事實的時候,我也同樣很吃驚。既然這些它都能實現,那它和class還能有什麼區別?最本質的一個區別就是預設的存取控制,體現在兩個方面:
Time of Update: 2018-12-05
文章目錄 Implicit conversionExplicit conversiondynamic_caststatic_castreinterpret_castconst_cast Type CastingConverting an expression of a given type into another type is known as type-casting. We have already seen some ways
Time of Update: 2018-12-05
今天碰到了需要在C++中使用C函數的問題,原先我以為直接在C++中引入C需要的標頭檔,然後在C++中使用相關的C函數就可以了,可是今天真試了一下卻發現編譯器報錯:"xxxx"在此範圍中尚未聲明。費了好大勁才在網上找到了答案,原來要使用extern關鍵字來指明這個函數的出處。 本人語言表達能力不行,話不多說,直接上代碼(註:這個代碼僅供參考,可能無法運行):/********MyButton.h*********/#ifndef MYBUTTON_H_#define
Time of Update: 2018-12-05
文章目錄 usingNamespace aliasNamespace std Namespaces allow to group entities like classes, objects and functions under a name.This way the global scope can be divided in "sub-scopes", each one with its own name.The format of
Time of Update: 2018-12-05
標題 Const用法小結 選擇自 yuguanglou 的 Blog 關鍵字 Const用法小結 出處 http://dev.csdn.net/develop/article/50/50538.shtm 1. const常量,如const int max = 100; 優點:const常量有資料類型,而宏常量沒有資料類型。編譯器可以對前者進行型別安全檢查,而對後者只進行字元替換,沒有型別安全檢查,並且在字元替換時可能會產生意料不到的錯誤(邊際效應) 2. const
Time of Update: 2018-12-05
文章目錄 Initialization of null-terminated character sequencesUsing null-terminated sequences of characters As you may already know, the C++ Standard Library implements a powerful string class, which is very useful to handle
Time of Update: 2018-12-05
Passing an Array to a FunctionLast updated Jun 17, 2005.In aprevious column, I claimed that passing an array as a function argument was impossible. The problem is that the array is implicitly converted, or decays, into a pointer. The pointer, alas,
Time of Update: 2018-12-05
在寫程式是經常會遇到這種情況:需要統計某一個類的所有對象執行個體的個數。一個比較簡單的方法是使用一個全域的變數,但是其缺點也是顯而易見的。使用static成員可以很好的解決這個問題。相對與使用全域變數使用static成員有以下優勢1)
Time of Update: 2018-12-05
眾所周知, NDK可以產生lib,讓java程式通過jni來調用,其實,NDK也可以產生C/C++的可執行程式.不過這個程式要被執行的話還有要求. 1.可執行檔的名字必須是lib*.so. 否則apk安裝時不會安裝上去,因為目前apk的安裝只支援安裝lib檔案,即lib*.so檔案,如果不是此檔案格式的,安裝時不會拷到lib目錄裡.也可以考慮把可執行檔放assets裡,java程式運行後把它拷貝到其它目錄或系統目錄.
Time of Update: 2018-12-05
代碼如下:#include <iostream>#include <vector>using namespace std;int main(){ cout << "c++ stl vector and iterator test!" << endl; cout << "increase number" << endl; vector<int> vec; vec.push_back(1);
Time of Update: 2018-12-05
#include <stdio.h>#include <pthread.h>#include <unistd.h>void *create(void *arg){ int *num; num=(int *)arg; printf("create parameter is %d\n",*num); return (void *)0;}int main(int argc,char *argv[]){ pthread_t tidp;