Home > Back-end >  19.7.9 namespace
19.7.9 namespace

Time:11-12

#include
#include

The namespace China {
Float population=14;//unit/$
STD: : string capital="Beijing"; }

The namespace Japan {
Float population=3.71;//unit/$
STD: : string capital="Tokyo"; }

Using China: : population;
using namespace std;
Int main (void) {
CoutSTD: : coutSTD: : coutCoutsystem("pause");
return 0;
}










The namespace China {
Float population=14;//unit/$
STD: : string capital="Beijing"; } braces don't need because is to define the namespace
on the outside of the semicolon
Namespaces to distinguish between the two is the main purpose of the same variables, constants, easy-to-read speak the there are two of the same name of the class, in order to distinguish respectively take a nickname or name, namespace is such a role,
  • Related