2013年3月13日 星期三

物件導向(1)


#include <stdio.h> → include interface ↔ 沒有include implementation
int main()
{
printf(“Hello World!\n”); → 第一個引數format string

return 0;
}

preprocessing(macro) → compiling → linking (才需要知道implementation 函式庫)
static dynamic

posix (portable operation system interface)
包含各種platform的實作

#include <stdio.h>
int stk[100]; → scope的問題 加上static解決問題
int sp = -1;
void push(int x) → 兩個stack 的問題 float double型別的stack問題
{            沒有encapsulation的問題
stk[++sp]=x;
}
int pop()
{
return stk[sp--];
}

ADT(Abstract Data Type)= Data + Operators(用來manipulate Data操作)

C++克服C的地方
encapsulation
inheritance(reuse)
polymorphism(switch)

沒有留言:

張貼留言