Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question about "using" keyword

Tags:

c++

I'm well aware of using namespaces however, every now and then I'm stumbling upon a using, which uses a specific class. For instance :

#include <string>
using namespace std;
(...)

However - every now and then, I'm seeing :

using std::string;

How should I interpret the "using" in this case ?

Cheers

like image 701
Maciek Avatar asked Nov 27 '22 23:11

Maciek


1 Answers

using std::string simply imports std::string into the current scope (aka, you can just use 'string' rather than 'std::string') without importing everything from ::std into the current scope.


edit: clarification after comment.

like image 198
Grant Limberg Avatar answered Dec 18 '22 19:12

Grant Limberg