Extreme programming

Nothing is impossilbe! Extreme Optimizing

Friday, January 05, 2007

Scenarios where you have to use member initialization list in C++

1. When initialize a reference member
2. When initialize a const member
3. When call a base class's constructor that requires a group of parameters
4. When call a member class's constructor that requires a group of parameters

Member initialization list is preferred to the initialization inside the constructor. The following is one example:

private:
String myName;
public:
Constructor()
{
myName = 0
........
}

In this case, a temp object will be created for 0, and copy that to myName, and finally destroy the temp object.

A revised approach is:

Constructor(): myName(0)

Two points are important to remember about the initialization list's operation
1) It happens before any explicit users code;
2) Its operating sequence is determined by the declaration sequence of those members in the class declaration, instead of their seen order found in the initialization list.

Labels: ,

Friday, February 18, 2005

C++ Programming in Game Development

Recently, I am reading "Beginning C++ Game Programming " ( by Michael Dawson ), which is an interesting book. It is suitable not only to C++ novices but experieced programmers. The most important point is that we can learn something in a exicting practical world: game programming.

Thursday, January 27, 2005

Oh, HelloWorld @ C#

using System;

class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello, world!");
}
}

Hello World

The first programming language I learned is Pascal, and no exception the first program I wrote is HelloWorld. Things happened again for three times when I learned C, C++ and Java. Even I onced wrote a HelloWorld m-file with Matlab. I am waiting for my first C# program, and I hope it will be HelloWorld again since I am a traditional man.