C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun Nov 12, 2006 9:12 am    Post subject: what mean: const A&a = A() ? Reply with quote



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





PostPosted: Sun Nov 12, 2006 9:48 am    Post subject: Re: what mean: const A&a = A() ? Reply with quote



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






PostPosted: Sun Nov 12, 2006 10:10 am    Post subject: Re: what mean: const A&a = A() ? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.