Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在以下示例中:
template<class Foo> struct FooBar { FooBar(Foo *pObj = 0) : pFoo_(pObj) {} };
“*pObj = 0”是什么意思?
这意味着pObj,如果调用者不提供,默认值为0。在这种特殊情况下,使用它会更好NULL(通常是 的宏0)。现在有两种调用方式:
pObj
0
NULL
FooBar fb = FooBar(); //pObj is NULL FooBar fb2 = FooBar(someFoo); //pObj is someFoo