By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,599 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,599 IT Pros & Developers. It's quick & easy.

what mean: const A&a = A() ?

P: n/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.

Nov 12 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ni**************@126.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

Nov 12 '06 #2

P: n/a
Thanks, that's very helpful
"Andrey Tarasevich д
"
ni**************@126.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
Nov 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.