Thursday, 15 January 2015

[C++] Abstract Class

只要類別含有任何一個 pure virtual function 就稱為 abstract class.

ex.
class Shape {  // abstract class
    virtual void rotate(int) = 0;  // pure virtual function
    virtual void draw() = 0;  // pure virtual function
    virtual bool is_closed = 0; // pure virtual function
    ...
};

abstract class 無法建立任何 object,只能做為其他 object 的 interface & base object

base:
ex.
class Point { /* */ };
class Circle : public Shape {
    public:
        void rotate(int) {}  // 覆蓋 Shape::rotate
        void draw();  // 覆蓋 Shape::draw
        bool is_closed() { return true; }  // 覆蓋Shape::is_closed

        Circle(Point p, int r);
    private:
        Point center;
        int radius;
};

interface:
ex. driver
class Character_device {
    public:
        virtual int open(int opt) = 0;
        virtual int close(int opt) = 0;
        virtual int read(char* p, int n) = 0;
        virtual int write(const char* p, int n) = 0;
        virtual int ioctl(int ...) = 0;
        virtual ~Character_device() {}
};
可從 Character_device 衍生出各式各樣的 driver object

有 abstract class 便能以 object 拼出完整模組化的系統。

Wednesday, 24 December 2014

Google Cardboard

Interesting!!
You only need a cardboard and an Android phone, you could start to develop VR!

Ref: https://www.google.com/get/cardboard/get-cardboard.html

Wednesday, 5 November 2014

Skin Button



Yeah, I've thought about doing smart phone as a projector, to be a big projector, to show image, slides, video, document...
something like that.
BUT! I've never thought about doing it as a tiny projector!
Such a nice idea!

refer: http://dl.acm.org/citation.cfm?id=2647356

Thursday, 21 August 2014

[C++] Container


size add delete access
vector size() push_back() pop_back() [], back()
list size() push_back() pop_back() back()
queue size() push() pop() back()
dequeue size() push_back(),
push_front()
pop_front(),
pop_front()
[], back()
priority_queue size() push() pop() top()
set size() iterators iterators iterators
multiset size() iterators iterators iterators
map size() iterators iterators [], iterators
multimap size() iterators iterators iterators