....
2014年11月20日 星期四
2014年11月18日 星期二
2014年11月15日 星期六
[長知識] C++ 的 Reference & Pointer (參考和指標)
Reference (參考) 和 Pointer (指標) 在C++內很重要,很重要,很重要,
因為很重要,所以我打了3次。
言歸正傳:
因為很重要,所以我打了3次。
言歸正傳:
[長知識] C++裡面的template,Java裡面的generic
對於一個寫過Java而還不熟C++的人來說
有著一個共通的地方
Java說這是泛型Generic
C++說這是樣板template
以下範例在說明:
有著一個共通的地方
Java說這是泛型Generic
C++說這是樣板template
以下範例在說明:
[長知識] c++ 要怎麼開始玩最快?
從c++開始,
我們要include的東西就不一樣了
原本C是 include <stdio.h> 和 <stdlib.h>
而C++則是 include <iostream>和<cstlib>
再來是重要的命名空間使用 using namespace std;
來說說有using和沒有using的差別好了
有using namespace std ,就直接可以使用cout和endl
例如: cout<<"hello world!<<endl;
沒有使用using namespace std,就不能直接使用cout和endl
例如: std::cout<<"hello world!<<std::endl;
差別就是每次要使用時,都必須要再寫一次 std::
下面這個範例是在說明:
我們要include的東西就不一樣了
原本C是 include <stdio.h> 和 <stdlib.h>
而C++則是 include <iostream>和<cstlib>
再來是重要的命名空間使用 using namespace std;
來說說有using和沒有using的差別好了
有using namespace std ,就直接可以使用cout和endl
例如: cout<<"hello world!<<endl;
沒有使用using namespace std,就不能直接使用cout和endl
例如: std::cout<<"hello world!<<std::endl;
差別就是每次要使用時,都必須要再寫一次 std::
下面這個範例是在說明:
2014年11月13日 星期四
[食記] 台中 黃鶴洞韓式料理(勤美店) - 銅盤烤肉/部隊火鍋
2014/11/14更新:
這家店似乎不受台中板友們喜愛
所以,想要去的人記得先去台中板爬文唷~
以下是我個人心得,可能當天有點餓,接受度就變高囉!
-----------------------------------------------------------------------------
用餐時間:2014.10.17 17:30
每次來勤美晃晃,就會看到這家店,而且都高朋滿座,似乎很夯~
我跟KEN就決定來吃看看!!!
( 但這天沒帶到相機...用手機拍請見諒~ )
這家店似乎不受台中板友們喜愛
所以,想要去的人記得先去台中板爬文唷~
以下是我個人心得,可能當天有點餓,接受度就變高囉!
-----------------------------------------------------------------------------
用餐時間:2014.10.17 17:30
每次來勤美晃晃,就會看到這家店,而且都高朋滿座,似乎很夯~
我跟KEN就決定來吃看看!!!
( 但這天沒帶到相機...用手機拍請見諒~ )
2014年11月12日 星期三
[長知識] C語言 - 陣列mixed指標
陣列即指標!
陣列名稱:指向陣列起始位址的指標
陣列名稱:指向陣列起始位址的指標
#include#include int main(){ int a[5] = P{1, 2, 3, 4, 5}; int i, n; printf("sizeof(a)%d\n",sizeof(a)); printf("sizeof(a[0])%d\n",sizeof(a[0]));
[長知識] C語言 - malloc()
p = (int*)malloc(sizeof(int));
malloc: 動態取得記憶體傳回指標。
#include#include int main(){ int *p; p = (int*)malloc(sizeof(int)); *p = 10;
[長知識] C語言 - 玩玩 參數傳值和傳址
#include#include //傳址,希望函數幫我改值的狀況就用傳址! int dayBetweenByAddress(int *in, int *out){ int temp; if(in >out){ temp = *in; *in = *out; *out = temp; } return *out-*in; }
2014年11月10日 星期一
[長知識] C語言 - 新手篇章 - 命名常數(pi)
#define 是在編譯時被執行!!
最常用的就是定義數學Pi = 3.1415926了
最常用的就是定義數學Pi = 3.1415926了
#include#include #define pi 3.1415926
[長知識] C語言 - 新手篇章 - 自訂函數
#include#include //Topic : 自訂函數 function //printf(), scanf() :內建函數,等待呼叫 //if, for, while :敘述 statement
訂閱:
文章 (Atom)