Почему класс с конструктором `=delete`d используется вместо `namespace`C++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Гость
 Почему класс с конструктором `=delete`d используется вместо `namespace`

Сообщение Гость »


Was studying C++ when this answer came across. It suggests a with purely members with instantiation intentionally disabled.
But if the shall not be instantiated, is there a reason

Код: Выделить всё

namespace
is not used instead? And if so or not, are there any other situations where using a d class constructor is better than using a

Код: Выделить всё

namespace
?
I've read this answer and with my understanding, it says

Код: Выделить всё

namespace
should not be used at all unless you really want to prevent name collisions, since es provides means for access control (, ,

Код: Выделить всё

protected
) and more features in general.
So if I were to answer my own question, it would be for better access control and just because it is a does not necessarily mean it has to be instantiated somehwere, albiet not feeling much object-oriented. This is to check if the understanding is correct or not, and what are all the more reasons to prefer a with d constructor over a

Код: Выделить всё

namespace
.


Источник: https://stackoverflow.com/questions/781 ... -namespace
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»