0

C++ library

in C++, what is the difference between #include and using namespace

16th Dec 2016, 3:54 PM
TARFAOUI Mohammed
2 Respuestas
+ 1
Hey , #include : the name itself defines its includes preprocessor directive that causes the named file. for example : include <iostream> all C++ programs Begin with a #include directive that includes the specified header file contents into main program The #include<iostream> preprocessor to add the content of the iostream file to the program. there are Hundreds of headed files in C++. I would list some of them 1. <cctype> 2.<cmath> 3.<cstdio> 4.<cstdlib> 5.<cstring> and lot more coming to namespace Namespace defines scope for the identifiers that are uses in a program. The best example for namespace is using namespace std; This tell to compiler that the members defined std namespace will be used frequently throughout the program. We can define our own namespace in our program example : namespace name { void fun(){}; //code ; } int main () { name:: fun(); //calls the fun function }
16th Dec 2016, 4:50 PM
Mock
Mock - avatar
0
namespaces are generally used to avoid name duplication of method , class, variable, function etc. for example different namespaces may contain varibale same variable name. so simply it is just used for logical separation. now include is just keyword in c to show that we are including definitions from other file.. in c++ we have using keyword for the same purpose but it need namespaces name instead of file name..
16th Dec 2016, 5:40 PM
Exception Handler
Exception Handler - avatar