15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Template classes w/o ctors

Ken Freeman -- kfreeman@viewlogic.com
Tuesday, February 06, 1996

I've noticed that the MFC template classes like CTypedPtrArray don't
have constructors defined.  (Take a look at afxtempl.h.)

This may be a C++ question: how is it that we are allowed to
instantiate objects of these classes?  Is there something special
about template classes?

Ken



Niels Ull Jacobsen -- nuj@kruger.dk
Thursday, February 08, 1996

> I've noticed that the MFC template classes like CTypedPtrArray don't
> have constructors defined.  (Take a look at afxtempl.h.)
> 
> This may be a C++ question: how is it that we are allowed to
> instantiate objects of these classes?  Is there something special
> about template classes?
> 
> Ken

No, it has nothing to do with templates. If a class hasn't got any
constructors, C++ will provide a default constructor.  This automatic
default constructor will call the base class default constructor and
the default constructors of any members. In the case of
CTypedPtrArray, this is exactly what we want.


--
Niels Ull Jacobsen, Kruger A/S

Everything stated herein is THE OFFICIAL POLICY of the entire Kruger
group and should be taken as legally binding in every respect. Pigs
will grow wings and fly.





| Вернуться в корень Архива |