Main Contents

Tag:C/C++

struct的特別用法

struct的特別用法

#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; c.down = 1; printf(”%d %d\n”, sizeof(Cell),...

default constructor

default constructor

C++中預設建構子就是沒有參數的建構子
一般大多數人都有以下錯誤觀念:1.class沒有定義預設建構子 compiler就會自動產生一個2.compiler產生出來的預設建構子中 會為member data設預設值

多型的陷阱

多型的陷阱

1: class A {…};2: class B {…};3: class C: public A, private B {…};
4: A a = new C();5: B b = new C();
在C++中,繼承有public, protected and private如果使用private的話 第5行編譯是不會過的 因為pri...

差點被考到的程式碼

差點被考到的程式碼

昨天面試 其中一個主管很在意coding能力我也跟他說我coding很好他就要考考我考了兩題後 他發現太無趣了 就從一堆題目中找了一題出來說這題過去沒幾個人講的出來
#define fun(A, b) (in...

Tag Cloud:



Feed