Meditation, The Art of Exploitation

Thinking? At last I have discovered it--thought; this alone is inseparable from me. I am, I exist--that is certain. But for how long? For as long as I am thinking. For it could be, that were I totally to cease from thinking, I should totally cease to exist....I am, then, in the strict sense only a thing that thinks.

Sunday, March 05, 2006

C++ how to declare a function in a class

I found the following exerpt from "The C++ programming language" 3rd edition insightful,

11.5 Friends [over.friends]
An ordinary member function declaration specifies three logically distinct things:
1. The function can access the private part of the class declaration, and
2. the function is in the scope of the class, and
3. the function must be invoked on an object (has a this pointer)

By declaraing a member function static, we can give it the first two properties only; by declaraing a function a friend, we give it the first property only.

Saturday, March 04, 2006

C++ return an array by reference

Use this trick declaration to return a reference of an array:

char ( &GetArray() )[6]
static char hello[] = "hello";
return hello;

c++ static member function and non-static member function

Other than the access modifier to a static member function, i.e. myclass::staticfunc(...). A static member function is essentially the same as a free function in the same namespace scope. Especially pointers to static member functions have the same type as to free functions. This means when a static member function is invoked, 'this' pointer is not passed as the first argument.

It's usually an overlooked fact that any call to a non-static member function has an implicit argument 'this'.

Thursday, March 02, 2006

Welcome to Fei Liu's Blog

I finally decided to use google's blog service instead of maintaining my own blog service using bloxsom on a linux machine. I intend to use this blog to keep track of knowledge and experience gained from life and work.