Being a good man is good, but hard.

June 10, 2011 Leave a comment

Shit thing happens.

shit thing always happens.

Categories: Uncategorized

Perl notes, day 1

May 20, 2011 Leave a comment

I will continue working on the C++ programming language. Now, I need to figure out how perl work and be able to write perl program before my first day of work begin.

1. variable in perl is alway global. all variable is global in the package.

2. funny characters in perl. Scalar variables are preceded by a dollar sign($). array variables are preceded by an at sign(@). associative array variables, called hashes are preceded by a percent sign %.

Categories: Uncategorized

C++ learning notes 5

April 29, 2011 Leave a comment

operator overloading:

::  .  .*

can not be overload.

an operator function must either be a member or take at least one argument of a user-defined type (functions redefining the new and delete operators need not).

Categories: Uncategorized

C++ learning notes 4

April 25, 2011 Leave a comment

there are some missings,

I just try to keep remember everything that I learned. Last two weeks is hard for me. So I skipped some post. The notes will not end. SO here we go.

use mutable can change value in a const function.

Categories: Uncategorized

Doomed!!! shit!!!!

April 13, 2011 Leave a comment

The multi-core programming professor is angry about sharing code stuff. What a shit day. Damn!!!!!!!!! I will never let other people get my fucking code!!!

Categories: Uncategorized

C++ self-learning notes day3

April 11, 2011 Leave a comment

using the same name for operations on different type is overloading.

compiler will automatic find the right version to call from a set of overloaded functions using best match. 1。 exact match, 2. match using promotions bool to in,char to int, short to int, unsigned to signed, float to double, double to long double. (turn to be more accurate). 3. match using standard conversions. int to double, double to int.

overloading can increase the chances that an unsuitable argument will be rejected by the compiler.

something interesting: For example, the menu system for my mousebased editor is implemented using arrays of pointers to functions to represent operations. (see the master always is also the craftman).

do not use macros unless you have to.

if use macros, use scope resolution operator :: when it referring the global names. enclosed occurrences of a macro argument name in parentheses whenever possible.

Categories: Uncategorized

C++ self learn note 2

April 9, 2011 Leave a comment

== has higher precedence than &;

y = ++x equals y = (x+=1);

y = x++ equals y = (t=x, x+=1,t)

operator new needs to allocate space for an object, it calls operator new() to allocate a suitable number of bytes. Similarly, when operator new needs to allocate space for an array, it calls operator new []();

new if no store, throws bad_alloc exception.

#include <iostream>
using namespace std;

void out_of_store(){
cerr << “operator new failed: out of store\n”;
throw bad_alloc();

int main(){

for(;;) new char[10000];
cout << “done” << endl;
return 0;

The code like this will throw an exception, then due to the alloc memory  is not free. so it will freeze the system.

Unless a variable is declared static, its initilizer is executed whenever the thread of control passes through the declared.

usually best to delay the definition of a local variable before its initial value is assigned.

About the comments:

1. is meaningfull

2. describes the program, and

3.  is up to date.

I:  a comment for each source file stating what the declarations in it have in common, references to manuals, general hints for maintenance.

II: A comment for each class, template , and namespaces;

III: A comment for each nontrivial function stating its purpose, and the algorithm used, some assumptions made this works.

IV: A comment for each global and namespace variable and constant.

V: do not command obvious thing.

VI: Very little else.


Categories: Uncategorized