Tag: C/C++
Singleton Pattern
四月.28, 2010 Posted in RSS
Singleton Pattern帶來的是保證一個class只有一個實體,無法產生第二個第三個… 使用這種模式的概念是系統中永遠只會唯一存在,如OS kernal、program core或hardward controller等。C++實作如下:
Comments Off
:C/C++, Design Pattern, Programming
more...
Policy-Based Class Design
四月.17, 2010 Posted in RSS
在C++新增template功能的初期,大家普遍認為template只是為物件導向設計得到更好的重用性,不單單將重複使用的程式碼設計成物件類別(class),連類別也重用,經由編譯器幫programmer把不同型別...
Invoke pure virtual function
十二月.11, 2009 Posted in RSS
沒錯 你沒看錯
這篇的標題是呼叫純虛擬函式
一個沒有實作的純虛擬函式是有可能被呼叫起來的
class A {
public:
virtual void f(void) = 0;
};
class B : public A {
...
C/C++ with MySQL
七月.28, 2009 Posted in RSS
最近一直找一個bug 找很久都找不出來
狀況是這樣子
在一台linux上裝上 MySQL 5.0, Apache 2.0, django 1.0, openssl 5.5.2
建立一台有網頁 有cgi 有ssl的平台
之後複製另一台成master an...
Virtual function: Differences between C++ and Java
五月.24, 2009 Posted in RSS
Purposes: Polymorphism (Dynamic Binding)
C++
Java
Pure Virtual Function
vitual void func() = 0;
abstarct void func();
Impure Virtual Function
vitual void func();
void f...
extern 與 extern “C”
十二月.08, 2008 Posted in RSS
整理一下看網友blog的文章筆記:
關於extern:
1. 在function外定義的變數就叫外部變數,相反的在function內就叫內部變數。2. 外部變數的視野是從定義的開始那行到本身檔案結束的最後一...
struct的特別用法
十一月.03, 2008 Posted in RSS
#include
typedef struct A {
int up : 1;
int down : 1;
int left : 1;
int right : 1;
}Cell;
int main(void) {
Cell c;
c.up = c.down = c.left = c.right = 0;
[...]<...
default constructor
十月.01, 2008 Posted in RSS
C++中預設建構子就是沒有參數的建構子
一般大多數人都有以下錯誤觀念:
1.class沒有定義預設建構子 compiler就會自動產生一個
2.compiler產生出來的預設建構子中 會為member data...
tricky skill (1) in C
九月.25, 2008 Posted in RSS
struct rumble {
char c[1];
};
struct rumble *p = (struct rumble*) malloc(sizeof(struct rumble) + 5);
在C裡 有一個技巧就是在struct最後宣告一個單一元素的陣列
於是在malloc時就能擁有可變...
Looking for something?
Use the form below to search the site:
Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!























