文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。
假设List是一个C++类的名字,问: List x 和 List x() 有区别么?
A big difference!
函数f()声明了一个名为x的List类的实例
void f()
{
List x; // Local object named x (of class List)
...
}
而函数g()声明的是一个名为x()的函数,它的返回值是一个List
void g()
{
List x(); // Function named x (that returns a List)
...
}
注意,这个和构造函数不一样(new List & new List())…