#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <climits>
#include <sstream>
#include <cstdlib>
using namespace std; /**
* 命名空间
*
*namespace identifier
*{
* named_entities
*}
*/
namespace foo
{
int value()
{
return 5;
}
} namespace bar
{
const double pi = 3.1416;
double value()
{
return 2 * pi;
}
} namespace first
{
int x = 5;
int y = 10;
} namespace second
{
double x = 3.1416;
double y = 2.7183;
} //int main()
//{
// cout << foo::value() << '\n';
// cout << bar::value() << '\n';
// cout << bar::pi << '\n';
// using first::x;
// using second::y;
// cout << x << endl;
// cout << y << endl;
// cout << first::y << endl;
// cout << second::x << endl;
// return 0;
//}
int x;
int main()
{
//using namespace和using的作用域
/*
{
using namespace first;
cout << x << '\n';
}
{
using namespace second;
cout << x << '\n';
}
//命名空间别名namespace new_name = current_name;
*/
//静态存储和自动存储
int y;
cout << x << '\n';
cout << y << '\n';
return 0;
}
/**
*
* The storage for variables with global or namespace scope is allocated for the entire duration of the program. This is known as static storage, and it contrasts with the storage for local variables (those declared within a block). These use what is known as automatic storage. The storage for local variables is only available during the block in which they are declared; after that, that same storage may be used for a local variable of some other function, or used otherwise.
*
*But there is another substantial difference between variables with static storage and variables with automatic storage:
*- Variables with static storage (such as global variables) that are not explicitly initialized are automatically initialized to zeroes.
*- Variables with automatic storage (such as local variables) that are not explicitly initialized are left uninitialized, and thus have an undetermined value.
*
*全局变量和命名空间是静态存储,在程序运行期间一直存在,本地变量是自动存储类型,只存在块内.
*
*俩个的不同点,静态存储的变量未初始化则默认值是0,自动存储变量值未初始化值是未确定
*
*/

  

c++官方文档-命名空间的更多相关文章

  1. clang format 官方文档自定义参数介绍(中英文)

    官方文档:http://clang.llvm.org/docs/ClangFormatStyleOptions.html 中文 在代码中配置样式 当使用 clang::format::reformat ...

  2. Spring JMS 官方文档学习

    最后部分的XML懒得写了,因为个人更倾向于JavaConfig形式. 为知笔记版本见这里,带格式~ 做了一个小demo,放到码云上了,有兴趣的点我. 说明:需要先了解下JMS的基础知识. 1.介绍 S ...

  3. Spring 4 官方文档学习(十一)Web MVC 框架

    介绍Spring Web MVC 框架 Spring Web MVC的特性 其他MVC实现的可插拔性 DispatcherServlet 在WebApplicationContext中的特殊的bean ...

  4. 【Docker官方文档】理解Docker

    本文来自Docker的官方文档,详细介绍了Docker的体系结构.重要概念.内部工作机理等内容,推荐不了解Docker内部原理的同学阅读. 什么是Docker? Docker是一个用于开发.交付和运行 ...

  5. gRPC官方文档(概览)

    文章来自gRPC 官方文档中文版 概览 开始 欢迎进入 gRPC 的开发文档,gRPC 一开始由 google 开发,是一款语言中立.平台中立.开源的远程过程调用(RPC)系统. 本文档通过快速概述和 ...

  6. 2017.4.10 spring-ldap官方文档学习

    官网:http://www.springframework.org/ldap 官方文档及例子(重要):http://docs.spring.io/spring-ldap/docs/2.1.0.RELE ...

  7. Protocol Buffers官方文档(proto3语言指南)

    本文是对官方文档的翻译,大部分内容都是引用其他一些作者的优质翻译使文章内容更加通俗易懂(自己是直译,读起来有点绕口难理解,本人英文水平有限),参考的文章链接在文章末尾 这篇指南描述如何使用protoc ...

  8. Hive官方文档

    Hive官方文档     内容列表 Cloudera制作的Hive介绍视频 安装与配置 系统需求 安装Hive发行版 从Hive源码编译 运行Hive 配置管理概览 运行时配置 Hive, Map-R ...

  9. 20191127 Spring Boot官方文档学习(9.1-9.3)

    9."使用方法"指南 9.1.Spring Boot应用程序 9.1.1.创建自己的FailureAnalyzer FailureAnalyzer被包装在FailureAnalys ...

随机推荐

  1. DS18B20配置

    复位脉冲: 先拉低至少480us,以产生复位脉冲,接着释放4.7k电阻为高,延时15~60us, 进入接收. void DS18B20_Rst(void) { DS18B20_IO_OUT(); // ...

  2. scroll滚动动画(js/ts)

    //(蓝色this部分为dom) scrollToLeft(option?: { duration?: number, direction?: number }) { let direction = ...

  3. ubuntu journalctl — 检索 systemd 日志

    常用: 查看最近1000行log sudo journalctl -f --lines=1000 -u server.$PROJECT_NAME --no-full, --full, -l 如果字段内 ...

  4. 10款PHP开源网店系统

    在当今经济危机的大环境下,网上购物越来越来吃香,网上开店成本低,快捷方便,出名的电子商务网站有淘宝,拍拍,Ebay或是最新的百度有啊,这些网站都提供开店的机会,如果是想自己搭建购物平台,可以从下面选择 ...

  5. SQLite数据库学习小结——Frameworks层实现

    3. SQLite的Frameworks层实现 3.1 Frameworks层架构 Android系统方便应用使用,在Frameworks层中封装了一套Content框架,之所以叫Content框架而 ...

  6. Thrift 个人实战--初次体验Thrift(转)

    前言: Thrift作为Facebook开源的RPC框架, 通过IDL中间语言, 并借助代码生成引擎生成各种主流语言的rpc框架服务端/客户端代码. 不过Thrift的实现, 简单使用离实际生产环境还 ...

  7. 剑指offer-顺时针打印矩阵-二维数组

    输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1     2  3    4 5     6  7    8 9   10 11 12 13 14 15 16 ...

  8. solr相关

    http://www.cnblogs.com/arli/ 博主介绍: 武汉理工大学计算机系 华为java工程师 华为企业版Hadoop工程师 华为大数据解决方案架构师 国盛天丰软件工程师

  9. 为什么有时候 php 没有写闭合标签结束符?

    找了一些资料,大家对PHP闭合标签的总结如下: 好处:如果这个是一个被别人包含的程序,没有这个结束符,可以减少很多很多问题,比如说:header, setcookie, session_start这些 ...

  10. ORTP&&RTSP

    ortp为了提高实时性使用UDP发送 rtsp建立了一个TCPserver,等待客户端连接,此时打开VLC播放器-->打开网络串流-->输入rtsp地址,会请求RTSP Server建立一 ...