W
Wayne Shu
Hey, guys.
There is a problem.
e.g.
template <typename T>
class foo
{
public:
foo();
~foo();
private:
static size_t bar;
};
template <typename T>
size_t foo<T>::bar = 0;
template <typename T>
foo<T>::foo()
{
++bar; // (1)
}
template <typename T>
foo<T>::~foo()
{
--bar; // (2)
}
Note the place (1), (2), it can be replaced with
++foo<T>::bar;
--foo<T>::bar;
The qualified name and unqualified name are all OK,
and most c++ book use the qualified name preferable.
I know that it is something related with the name lookup.
but I don't know the details.
Does it have somebody explain it for me??
thanks.
Regards.
There is a problem.
e.g.
template <typename T>
class foo
{
public:
foo();
~foo();
private:
static size_t bar;
};
template <typename T>
size_t foo<T>::bar = 0;
template <typename T>
foo<T>::foo()
{
++bar; // (1)
}
template <typename T>
foo<T>::~foo()
{
--bar; // (2)
}
Note the place (1), (2), it can be replaced with
++foo<T>::bar;
--foo<T>::bar;
The qualified name and unqualified name are all OK,
and most c++ book use the qualified name preferable.
I know that it is something related with the name lookup.
but I don't know the details.
Does it have somebody explain it for me??
thanks.
Regards.