KEEP K.I.S.S.

tk's blog

以前写的一些东西

  • 一个C++的矩阵模板类,带有常见运算和求逆等功能:Matrix.zip
  • 一个VC6.0写的右键打开菜单添加器,源码程序

 

也就这些了,以前放在GAE搭建的博客上,现在上不去了,而且GAE收费了,所以转移下。

指针也许比引用更好~。~

 

        这是Qt开发者网站的一片文章的节选,讲述API的设计原则的,里面有一段关于C++中需要修改实参的函数的参数是选择指针还是引用的区别。然后,Qt里面选择了指针。因为调用这种函数的时候可以让人一眼看出这个函数调用会修改实参的值。

原文章:http://developer.qt.nokia.com/wiki/API_Design_Principles

C++ Specifics

Value vs. Object

Pointers vs. References

Which is best for out-parameters, pointers or references?

 

void getHsv(int *h, int *s, int *v) const
void getHsv(int &h, int &s, int &v) const

Most C++ books recommend references whenever possible, according to the general perception that references are “safer and nicer” than pointers. In contrast, we at Qt Software tend to prefer pointers because they make the user code more readable. Compare:

 

color.getHsv(&h, &s, &v);
color.getHsv(h, s, v);

Only the first line makes it clear that there’s a high probability that h, s, and v will be modified by the function call.