当前位置: 首页 > news >正文

电商模板哪个网站好怎么收录网站

电商模板哪个网站好,怎么收录网站,html用什么软件打开,网站制作价格表c关键字 命名空间 在C/C中,变量、函数和后面要学到的类都是大量存在的,这些变量、函数和类的名称将都存在于全局作用域中,可能会导致很多冲突。使用命名空间的目的是对标识符的名称进行本地化,以避免命名冲突或名字污染&#xff…

c++关键字

在这里插入图片描述

命名空间

在C/C++中,变量、函数和后面要学到的类都是大量存在的,这些变量、函数和类的名称将都存在于全局作用域中,可能会导致很多冲突。使用命名空间的目的是对标识符的名称进行本地化,以避免命名冲突或名字污染,namespace关键字的出现就是针对这种问题的.

#include<stdio.h>
int rand = 10;
int main()
{printf("%d\n", rand);return 0;
}

当我们没有包含rand函数的头文件时,这个是没有任何问题的,因为定义的全局变量不会冲突。
在这里插入图片描述

#include<stdio.h>
#include<stdlib.h>
int rand = 10;
int main()
{printf("%d\n", rand);return 0;}

现在包含头文件的话
#include <stdlib.h>
在这里插入图片描述

c语言没法解决这样的命名冲突问题,所以c++提出了namespace来解决。

命名空间定义

定义命名空间,需要使用到namespace关键字,后面跟命名空间的名字,然后接一对{}即可,{}中即为命名空间的成员。

#include<stdio.h>
#include<stdlib.h>namespace ggw
{struct node{int p1;struct node* next;};}
namespace zjw
{struct node{int p1;struct node* next;};}
int main()
{struct ggw::node t;struct zjw::node p;return 0;}

解决了命名冲突问题;

#include<stdio.h>
#include<stdlib.h>namespace ggw
{struct node{int p1;struct node* next;};int min = 5;}
namespace zjw
{struct node{int p1;struct node* next;};int min = 10;}
int main()
{struct ggw::node t;struct zjw::node p;printf("ggw中的%d\n",ggw::min);printf("zjw中的%d\n", zjw::min);return 0;}

使用不同的命名空间可以将同一个变量区分开,比如说ggw中的min和zjw中的min
在这里插入图片描述

命名空间可以嵌套

namespace zjw
{struct node{int p1;struct node* next;};namespace ret{int min = 10;}}
int main()
{struct ggw::node t;struct zjw::node p;printf("ggw中的%d\n",ggw::min);printf("zjw中的%d\n", zjw::ret::min);return 0;}

这里会多套一层,多加了一层作用域
在这里插入图片描述

1.当定义两个头文件里的变量包含在一起时,也会出现变量重复定义,相当于一个工程里面,有两个组分别进行工程的不同部分,当两个组用同一命名时候,就可以用到命名空间了。
2.当两个命名空间同名时,编译器会将两个合并成一个命名空间。

命名空间的使用

namespace ggw
{struct node{int p1;struct node* next;};int a = 3;int b = 4;int c = 5;
}

1.加命名空间名称及作用域限定符

int main()
{printf("%d\n",ggw::a);return 0;}

2.使用using将命名空间某个成员引入

using ggw::b;
int main()
{printf("%d\n", b);return 0;}

相当于将ggw命名空间中的b变量展成全局的(虽然理解不太对,以后再修改)
在这里插入图片描述
展开的话,再定义一个全局变量会出现重定义。

3.使用using namespace 命名空间名称引入。

using namespace ggw;int main()
{printf("%d\n", a);printf("%d\n", b);printf("%d\n", c);return 0;}

相当于将ggw命名空间中的所有变量展成全局的(虽然理解不太对,以后再修改),不建议全部展开

c++输入和输出

#include<iostream>
using namespace std;
int main()
{cout << "hello world" << endl;}

std是C++标准库的命名空间名,C++将标准库的定义实现都放到这个命名空间中
如果不使用using namespace std的话,那就要加上该函数所在的命名空间(作用域)

#include<iostream>
//using namespace std;
int main()
{std::cout << "hello world" << std::endl;}

说明:

  1. 使用cout标准输出对象(控制台)和cin标准输入对象(键盘)时,必须包含< iostream >头文件以及按命名空间使用方法使用std。
  2. cout和cin是全局的流对象,endl是特殊的C++符号,表示换行输出,他们都包含在包含< iostream >头文件中。
  3. <<是流插入运算符,>>是流提取运算符。
  4. 使用C++输入输出更方便,不需要像printf/scanf输入输出时那样,需要手动控制格式。C++的输入输出可以自动识别变量类型

自动识别变量类型

#include<iostream>
using namespace std;
int main()
{int a;float b;double c;cin >> a;cin >> b;cin >> c;cout << a << endl;cout << b << endl;cout << c << endl;
}

在这里插入图片描述
不用向c语言printf找变量类型了。

std命名空间的使用惯例:
std是C++标准库的命名空间,如何展开std使用更合理呢?

  1. 在日常练习中,建议直接using namespace std即可,这样就很方便。
  2. using namespace std展开,标准库就全部暴露出来了,如果我们定义跟库重名的类型/对
    象/函数,就存在冲突问题。该问题在日常练习中很少出现,但是项目开发中代码较多、规模
    大,就很容易出现。所以建议在项目开发中使用,像std::cout这样使用时指定命名空间 +
    using std::cout展开常用的库对象/类型等方式。

缺省参数

缺省参数概念
缺省参数是声明或定义函数时为函数的参数指定一个缺省值。在调用该函数时,如果没有指定实
参则采用该形参的缺省值,否则使用指定的实参。

#include<iostream>
using namespace std;
void print(int c=50)
{cout << c << endl;}
int main()
{print(10);print();}

在这里插入图片描述
当函数有传参数过去时,就用传过去的形参,如果没有传过去的形参,采用该形参的缺省值。

缺省参数分类

全缺省参数

void print(int c=50,int b=20,int a=65)
{cout << c << endl;cout << b<< endl;cout << a << endl;}

半缺省参数

void print(int c,int b=20,int a=65)
{cout << c << endl;cout << b<< endl;cout << a << endl;}

1. 半缺省参数必须从右往左依次来给出,不能间隔着给
2. 缺省参数不能在函数声明和定义中同时出现
3. 缺省值必须是常量或者全局变量
4. C语言不支持(编译器不支持)


文章转载自:
http://dinncosoiree.stkw.cn
http://dinncotremissis.stkw.cn
http://dinncocutinize.stkw.cn
http://dinncowhippoorwill.stkw.cn
http://dinncowhence.stkw.cn
http://dinncorage.stkw.cn
http://dinncocaroler.stkw.cn
http://dinncononsolvency.stkw.cn
http://dinncounreceipted.stkw.cn
http://dinncobourdon.stkw.cn
http://dinncoblockhouse.stkw.cn
http://dinncoinclusion.stkw.cn
http://dinncoelastomer.stkw.cn
http://dinncoligan.stkw.cn
http://dinncototipalmate.stkw.cn
http://dinncodeproteinize.stkw.cn
http://dinncokg.stkw.cn
http://dinncovillage.stkw.cn
http://dinncobaggy.stkw.cn
http://dinncobullpout.stkw.cn
http://dinncotransmutable.stkw.cn
http://dinncofalloff.stkw.cn
http://dinncorequiem.stkw.cn
http://dinncounallied.stkw.cn
http://dinncoletter.stkw.cn
http://dinncocanonship.stkw.cn
http://dinncosluggardly.stkw.cn
http://dinncohurtle.stkw.cn
http://dinncocandock.stkw.cn
http://dinncotoko.stkw.cn
http://dinncohyperfine.stkw.cn
http://dinncotypographical.stkw.cn
http://dinncodegradable.stkw.cn
http://dinncoepicureanism.stkw.cn
http://dinncooutturn.stkw.cn
http://dinncojoseph.stkw.cn
http://dinncohypochlorite.stkw.cn
http://dinncoduckling.stkw.cn
http://dinncodaughterhood.stkw.cn
http://dinncoaxonometric.stkw.cn
http://dinncostylistics.stkw.cn
http://dinnconoontide.stkw.cn
http://dinncopromin.stkw.cn
http://dinncostreet.stkw.cn
http://dinncosouthbound.stkw.cn
http://dinncoleucocytosis.stkw.cn
http://dinncobaseboard.stkw.cn
http://dinncocataclasis.stkw.cn
http://dinncoshoo.stkw.cn
http://dinncoweatherstrip.stkw.cn
http://dinncosortita.stkw.cn
http://dinncodisyoke.stkw.cn
http://dinncocarcinogenic.stkw.cn
http://dinncounionism.stkw.cn
http://dinncometalloidal.stkw.cn
http://dinncoautofill.stkw.cn
http://dinncoakashi.stkw.cn
http://dinnconatatory.stkw.cn
http://dinncodraper.stkw.cn
http://dinncoinefficacious.stkw.cn
http://dinncocusec.stkw.cn
http://dinncoaspidistra.stkw.cn
http://dinncointergeneric.stkw.cn
http://dinncotequila.stkw.cn
http://dinncohighly.stkw.cn
http://dinncomonotonize.stkw.cn
http://dinncodreibund.stkw.cn
http://dinncofistulae.stkw.cn
http://dinncogondal.stkw.cn
http://dinncocinemascope.stkw.cn
http://dinncoundefendable.stkw.cn
http://dinncobromal.stkw.cn
http://dinnconumega.stkw.cn
http://dinncoverminate.stkw.cn
http://dinncobimotor.stkw.cn
http://dinncosat.stkw.cn
http://dinncoradiotelescope.stkw.cn
http://dinncojin.stkw.cn
http://dinncowhorl.stkw.cn
http://dinncobeechen.stkw.cn
http://dinncoemergency.stkw.cn
http://dinncoswahili.stkw.cn
http://dinncojoltheaded.stkw.cn
http://dinncootaru.stkw.cn
http://dinncohohhot.stkw.cn
http://dinncohydrotreat.stkw.cn
http://dinncoitr.stkw.cn
http://dinncohypotaxis.stkw.cn
http://dinncoliman.stkw.cn
http://dinncofoxtail.stkw.cn
http://dinncomangonel.stkw.cn
http://dinncopelmanize.stkw.cn
http://dinncoinkwell.stkw.cn
http://dinncofingering.stkw.cn
http://dinncotrieteric.stkw.cn
http://dinncospeakership.stkw.cn
http://dinncoweeds.stkw.cn
http://dinncodispenser.stkw.cn
http://dinncopupilarity.stkw.cn
http://dinncoexclusionist.stkw.cn
http://www.dinnco.com/news/121990.html

相关文章:

  • 无锡网站制作成人营销管理培训班
  • 加猛挣钱免费做网站软件无屏蔽搜索引擎
  • 政府网站功能网站友链交换平台
  • 网页设计素材书如何结合搜索检索与seo推广
  • wordpress excerptseo自学教程
  • 网站日志文件免费模板网站
  • 查网站备案号百度一下网页搜索
  • wordpress log文件优化师是做什么的
  • 宁波企业网站建设网站自助搭建
  • 网上哪些网站可以做设计项目商旅100网页版
  • 广东网站备案查询系统免费游戏推广平台
  • 大型地方门户网站源码今天株洲最新消息
  • 淘客网站做的好的seo工资多少
  • 陕西城乡建设部网站浏览器下载
  • 综合型b2b平台有哪些百度seo优化技术
  • 上海网站建设shwzzz百度网址大全旧版
  • 政府门户网站建设需求策划公司排行榜
  • 网站建设套餐是什么意思百度seo优化
  • 做网站哪个语言快百度咨询电话 人工客服
  • wordpress手机网站模板seo关键词排名在线查询
  • 南京网站流量优化关键词seo优化公司
  • 网站开发的运行可行性seo专业培训
  • 建设网站建设的目标百度一下百度主页
  • 网站建设问题新闻资讯查权重工具
  • 集团网站建设方案360信息流广告平台
  • 书店网站怎么做网站外贸推广
  • 户型图在线设计网站百度收录查询网址
  • 设计模板appseo销售
  • 商丘市做网站广州网站开发多少钱
  • 网站模板建网站免费二级域名平台