Is there a C ++ equivalent for Python "import bigname as b"?

I always liked Python

import big_honkin_name as bhn

so you can just use bhn.thing, and not significantly more verbose big_honkin_name.thingin your source.

I saw the use of two types of namespace in C ++ code:

using namespace big_honkin_name; // includes fn().
int a = fn (27);

(which I'm sure is bad) or:

int a = big_honkin_name::fn (27);

Is there a way to get Python functionality in C ++ code, for example:

alias namespace big_honkin_name as bhn;
int a = bhn::fn (27);
+5
source share
6 answers
namespace bhn = big_honkin_name;

There is another way to use namespaces:

using big_honkin_name::fn;
int a = fn(27);
+12
source

fooobar.com/questions/10014 / ... Yes you can. In short:

namespace bhn = big_honkin_name;
+12
source

..

namespace bhn = big_honkin_name;
+6

using big_honkin_name::fn;

fn big_honkin_name,

int a = fn(27);

. (- , ), :

int big_honkin_object_name;

:

int& x(big_honkin_object_name);

x , big_honkin_object_name. .

+2
using namespace big_honkin_name;

. . , , , .

( , .)

, , :

namespace big = big_honkin_name;
+1

, ++ Python:

Python to ++

import someLib as sl = > namespace sl = someLib;

from someLib import func β†’ using someLib::func;

from someLib import * β†’ using namespace someLib;

note that before that you must do #include<someLib>in C ++.

the latter is known!

#include<iostream>
using namespace std;
0
source

All Articles