 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sun Nov 12, 2006 9:12 am Post subject: what mean: const A&a = A() ? |
|
|
hello,
here is an example: in class vector
explicit vector(size_type n, const T& val = T(), const A&a =
A()):alloc(a)
{...}
vector I mentioned above is a constructor of a template class:
template <class T, class A = allocator<T> > class vector{...};
so, I don't know what means = A(), because A is a typename here. Thank
you very much. |
|
| Back to top |
|
 |
Andrey Tarasevich Guest
|
Posted: Sun Nov 12, 2006 9:48 am Post subject: Re: what mean: const A&a = A() ? |
|
|
nicknamenickname (AT) 126 (DOT) com wrote:
| Quote: | ...
so, I don't know what means = A(), because A is a typename here. Thank
you very much.
...
|
If 'A' is a type, 'A()' is an expression that evaluates to a
default-initialized object of type 'A' (a _value_-initialized object of
type 'A' in post-TC1 C++). For example, 'int()' evaluates to 0.
'double()' evaluates to 0.0. 'std::string()' produces a
default-constructed temporary object of type 'std::string'. And so on.
--
Best regards,
Andrey Tarasevich |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Nov 12, 2006 10:10 am Post subject: Re: what mean: const A&a = A() ? |
|
|
Thanks, that's very helpful
"Andrey Tarasevich дµÀ£º
"
| Quote: | nicknamenickname (AT) 126 (DOT) com wrote:
...
so, I don't know what means = A(), because A is a typename here. Thank
you very much.
...
If 'A' is a type, 'A()' is an expression that evaluates to a
default-initialized object of type 'A' (a _value_-initialized object of
type 'A' in post-TC1 C++). For example, 'int()' evaluates to 0.
'double()' evaluates to 0.0. 'std::string()' produces a
default-constructed temporary object of type 'std::string'. And so on.
--
Best regards,
Andrey Tarasevich |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|