S
S
sanek20052021-11-23 16:58:59
C++ / C#
sanek2005, 2021-11-23 16:58:59

When should you create your own namespaces?

In what situations in C++ code should you create your own namespaces?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
calculator212, 2021-11-23
@calculator212

In my opinion, this should be done in almost any program, because. this will protect against duplication of function names, and it's easier to navigate through pieces of code this way, and it's a convenient method to split code into modules.

U
User700, 2021-11-23
@User700

When a system of classes, constants, functions, possibly global variables and objects arises, which describes the essence of one task or a set of related tasks and creates tools for solving them, for any actions with these entities.
For example, a namespace containing classes for describing sockets, IP addresses, connections, functions for creating a connection, accepting an incoming request, sending and receiving data. Or another example: a set of different algorithms for working with matrices, defining the type "matrix" and "vector" as standard or user-defined using / typedef.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question