C
C
chikik2020-08-25 18:23:36
C++ / C#
chikik, 2020-08-25 18:23:36

Library and namespace. What is the difference?

Why a library and a namespace in C++ are not the same. Both the library and the namespace contain functions and operators created by other programmers, as I understand it. For example, "iostream" contains certain functions and "std" contains functions, but iostream is a library and std is a namespace. Maybe I didn't read it right or didn't get the point. Please explain what is the difference between them?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AnT, 2020-08-25
@chikik

You have some strange terminological mess.
First, "library" and "namespace" are entities that have nothing in common even remotely. Your question sounds like "what is the difference between a crow and the area of ​​a triangle". It is impossible to answer such a question without further explanation - it is meaningless.
Secondly, there is no "iostream library" and there never was. Why are you suddenly calling "iostream" a "library"? C++ has a standard header <iostream> containing descriptions of entities from the C++ standard library . But the header is not a library at all. Nobody considers it <iostream>a "library". Why are you suddenly doing this?

V
Vlad _, 2020-08-25
@SimonMiler

A library can have many namespaces!

R
res2001, 2020-08-25
@res2001

When you write code, you are working with a namespace.
After you have compiled your program and run it, the program works with the library, there are no more namespaces there.
A library can have several namespaces or not one (more precisely, the entire library is placed in one global namespace).
If you go down, then the library is a *.dll and / or *.lib file (for Windows), the namespace is declared in *.h files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question