Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the basic difference between namespace , library and header files?

I was searching on the internet about the differences between namespace , header file and library but I am still confused that what is the basic difference between them , please give an answer in the context of programming language not any specific language like C or C++

like image 594
SFAH Avatar asked Nov 08 '22 01:11

SFAH


1 Answers

Namespace

A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.

Library

In programming, a library is a collection of precompiled routines that a program can use. The routines, sometimes called modules, are stored in object format. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.

Header Files

Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition.

thanks

like image 70
rahul rathore Avatar answered Dec 10 '22 02:12

rahul rathore